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
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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.