I cannot get "getJSON" to work. It is not executing. If I put the URL into a browser it downloads the data, so I know the URL is correct. I have included some HTML here that is nearly the entire HTML file that I am using. I have omitted the URL since it requires a login to work.
Could the login be a problem? As I said, the URL works if I use it in a browser; I am logged into the web site and obviously that is being used when I put the URL directly into a browser.
src="http://code.jquery.com/jquery-1.10.2.js">
When I press "Go" I get "start | | end" which indicates that getJSON is not executing or at least not working.


Sunny SharmaRank #223 · 11.1K reputationPosted Mar 18, 2014, 10:21 PM EDT
$.getJSON is asynchronous but seems you're expecting it to be synchronous.
You can use $.ajax in order to achieve synchronous response:
function GetMembers() {
var url="sample.json";
var message = "start | ";
message += $.ajax({
type: "GET",
url: 'sample.json',
async: false
}).responseText;
message += " | end";
json.innerText = message;
}
Hope it helps!
Sam HobbsRank #107 · 20.5K reputationPosted Mar 18, 2014, 11:36 PM EDT