Recent Posts

Showing posts with label Asycronous call. Show all posts
Showing posts with label Asycronous call. Show all posts

Javascript: How to return response from asynchronous ajax call

The next piece of code tries to return the response fron an ajax asynchronous call but with this we can only get undefined values: function foo() { var result; $.ajax({ url: '...', success: function(response) { result = response; // return response; // <- tried that one as well } }); return result; } var result = foo(); // always ends up being `undefined`. The...

How to: Make asyncronous call to file with PHP

make_request('http://www.externalsite.com/script1.php?variable=45'); //example usage $output = make_request('http://www.externalsite.com/script2.php?variable=45'); echo $output; //string output file_get_contents will do what you want $output = file_get_contents('http://www.example.com/'); echo $output; One way to fire off a GET request...