I'm getting an object from an ajax call, but I need the string instead. What should I do instead?
//some code...
$.ajax({
type: "POST",
url: action,
data: { pictureID: pictureID, comment: comment },
error: function(xhr,status,error){alert(error);},
complete:function(data) {
document.getElementById(outputID).innerHTML = data;
} //end of complete:function(data)
}); //end of $.ajax({
<?php
echo "test";
?>
[object Object]
test
Change the method from Complete to Success
$.ajax({
type: "POST",
url: action,
data: { pictureID: pictureID, comment: comment },
error: function(xhr,status,error){alert(error);},
success:function(data) {
document.getElementById(outputID).innerHTML = data;
}
});
The first argument to the complete function is a jqXHR, not the response
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.