views:

39

answers:

2

Hi All.

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!

+4  A: 

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

Drackir
yeah, because in userxxx's example it actually tries to call ` http://www.example.org/localhost/val.php `
joni
Fantastic, Did exactly what I needed it to! :) Thanks.
Glad to help. :)
Drackir
+1  A: 

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

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