-1

I have a page "jsonencode.php" containing encoded arrays

[["Easth1","North1","A","URL1"],["Easth2","North2","B","URL2"]]

I know I can load in html in to a div with:

$("#div").load("jsonencode.php");

but I want to do is load arrays into a variable like:

var a = load("jsonencode.php");
Nonemoticoner
  • 650
  • 5
  • 14
Udi Nugroho
  • 1
  • 1
  • 4
  • The possibility to `await` an operation safely is [under consideration for the language](https://github.com/tc39/ecma262#current-proposals). In the meantime, synchronous I/O is generally to be avoided in JavaScript as it halts the execution of your entire application while it waits. This makes for a terrible user experience. Avoiding that requires you, as the developer, to accept alternate techniques for writing your application – using callbacks, promises, etc. Related: [How do I return the response from an asynchronous call?](http://stackoverflow.com/questions/14220321/) – Jonathan Lonowski Mar 26 '16 at 17:34

1 Answers1

0
jQuery.getJSON('jsonencode.php', function(obj) {
    //obj not holds your parsed JSON as a JS object
});

http://api.jquery.com/jquery.getjson/

Mitya
  • 33,629
  • 9
  • 60
  • 107