I have a jQuery AJAX call with type:’GET’ like this:
$.ajax({type:'GET',url:'/createUser',data:"userId=12345&userName=test",
success:function(data){
alert('successful');
}
});
In my console output is:
GET:http://sample.com/createUser?userId=12345&userName=test
params: userId 12345
userName test
In my script i should get the value using $_GET[‘userId’] and $_GET[‘userName’] but i can’t get the value passed in by ajax request using GET method.
Any ideas on how to do this?
thanks,
The only thing I can see wrong with the code (which no longer applies as the question has been edited (which suggests that the code has been rewritten for the question and might not accurately reflect the actual code in use)) is that the success function is in the wrong place.
You have:
which should be:
Despite this, your description of the console output suggests the data is being sent correctly. I’d try testing with this script to see what PHP actually returns (you can see the body of the response in the Firebug console):