-1

I am new here, and I have looked at the other Ajax Help topics, however, I still can't see why mine isn't working.

Here it is:

$(document).ready(function(){
    $.ajax({
        type: "GET",
        url: "localhost/val.php",
        data: "val=RichieC",
        success: function(msg){
            alert("WOO");
        }
    });
});

Has anyone got any ideas? I've tried a few things!

Thanks!

3
  • Any error messages? What exactly is 'not working'? Commented Oct 25, 2010 at 16:00
  • Which part isn't working?.. Is the success callback just not firing? Have you tried adding an error callback and see if it gets called? Commented Oct 25, 2010 at 16:00
  • Can you post an example of the data coming back? If the data coming back is not valid then jQuery will tend to discard it. Commented Oct 25, 2010 at 16:01

2 Answers 2

4

Try putting http://localhost/val.php in the url. The way it is now will look for a localhost folder in the current directory.

Sign up to request clarification or add additional context in comments.

2 Comments

yeah, because in userxxx's example it actually tries to call ` example.org/localhost/val.php `
Fantastic, Did exactly what I needed it to! :) Thanks.
1

Did you debug val.php and verify that your server side code is running when you make the AJAX call? If your action is executing, you can make sure everything is working as expected by just stepping through (or alternatively, as Quintin Robinson suggested, you could add a failure callback to see if that is being called).

If your action is doing what you think it should do and still no callbacks are firing, well, that one's a toughie :)

1 Comment

Thanks! However, the val.php was only very simple, it was only a test script. I'm just trying to get the hang of AJAX and jQuery :) But thanks anyways!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.