Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jQuery ajax not returning timely

Status
Not open for further replies.

Geates

Programmer
Aug 25, 2009
1,566
US
I am creating a modal website that uses jQuery ajax calls to retieve HTML and load a modal. When running the site locally, the ajax command executes completely and returns results. However, once it is uploaded to the server, the modal does not get filled. I've considered it being because the call is asynchronous and the other commands have completed by the time ajax returns a value, but ajax isn't even returning a value at all. Including an error function lends no clues. Any idea?

Code:
function doAJAX(url){
   var content = null;
   $.ajax({
      type: "POST",
      url: url,
      success: function(response) {
         [red]alert(response);[/tt]
         content = response;
      },
      error: function(msg) {
         alert(msg);
      }
   });

   return content;
}

var html = doAJAX("something.php");
$("#modal").html(html);

-Geates

"I do not offer answers, only considerations."
- Geates's Disclaimer

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top