Sunday, 18 August 2013

AJAX Call Not Sending Success Response

AJAX Call Not Sending Success Response

//MAKE AJAX CALL TO REPOPULATE TABLE
var newData = 'page_number=1&type=2';
var that = this;
$.ajax({
type: 'POST', // HTTP method POST or GET
url: 'http://www.myurl.net/form_validate.php', //Where to make
Ajax calls
dataType:'text', // Data type, HTML, json etc.
data:newData, //post variables
success:function(response){
//REFORMAT UPON SUCCESSFUL AJAX CALL
alert(response);
},
error:function (xhr, ajaxOptions, thrownError){
alert(xhr + " " + ajaxOptions + " " + thrownError);
//throw any errors
}
});
All I've put in my PHP file is:
<?php echo "test"; ?>
When I go straight to that file, it echoes 'test.' When I try to run the
AJAX function on the click of a button it gives me the error:
[object Object] error
in an alert window. I've put the absolute URL to the file because I was
thinking that the relative linking I was using was wrong but it now seems
like it's some other issue. Am I overlooking a simple syntax error? Sorry
if this is super basic but I can't seem to figure this out after working
on it for a really long time. Thanks for your help.

No comments:

Post a Comment