Make get function Sycronous / Javascript

Posted by DDL449 on Stack Overflow See other posts from Stack Overflow or by DDL449
Published on 2012-06-10T22:36:51Z Indexed on 2012/06/10 22:39 UTC
Read the original article Hit count: 150

Filed under:
|
|
|

I'm experiencing a problem of $.get function. The url contains JSON

this is my code:

 xyz = null


    $.get('http://www.someurl.com/123=json', function(data) {
       var xyz = data.positions[0].latitude;
    });


alert(xyz);
//some more code using xyz variable

I know that xyz will alert a null result because the $.get is asychronous.

So is there any way I can use the xyz outside this get function?

Thank you

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery