0

I am using the following code to get data from a php file to a variable 'line'. But I don't know why, when I alert its value outside, it show empty. Here is the code:

var line = "something"
function generateNewLine(line)
      {
        $.get("getLine.php", function( data ) {
          line = data
          alert(line) // prints the data
        });

        alert(line) // prints nothing
      }
Gijo Varghese
  • 11,264
  • 22
  • 73
  • 122

0 Answers0