Jump to content

jQuery ajax load() function problem...


ds111

Recommended Posts

Hello,

 

I am developing an application that heavily uses jQuery. Although I'm really good with PHP, I'm completely new to jQuery. So i found the $("#id").load("http://url....."); function. I also use the jquery ajax form plugin.So basically, this is whats going.

 

The HTML:

<div id="results"></div>

...an html form...

 

The JS:

 

$(document).ready(function() {

 

                $("#result").load("http://www.url.com/test.php)

       

});

 

 

 

The PHP:

 

echo '<script>alert("Test");</script>';

 

 

 

I know the JS works because if i put alert() infront of it, it works. So how come the PHP code doesnt load and the JS code go into the div "results"?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/161595-jquery-ajax-load-function-problem/
Share on other sites

Do you want this alert when the ajax is call is completed? If thats what you want look into the oncomplete or onsuccess events for the ajax functionality in the jQuery documentation. Echoing out javascript in the php file thats being called using ajax is usually something you want to avoid

Your div's ID is 'results' and in your javascript you're using 'result'.

 

If that was only a typo when making the post, post you're javascript code that is being echoed.  Use code tags this time though :D

 

edit: you're also missing a double quote on your load() function

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.