Ajax is returning empty string
Below is my AJAX call to my test.php page. When returned, I'm getting a blank line.
$.ajax({ type: "POST", url: "test.php", data: 'action='+action+'&workOrderID='+value+'&wid='+wid+'&eid='+eid+'&lastName='+lastName+'&firstName='+firstName+'&finalComment='+comment, dataType: "json", error: function(xhr, ajaxOptions, thrownError) { console.log(data); alert(data); alert("Work Order NOT Updated."); }, success: function(data) { console.log(data); alert(data); alert("Work Order Updated."); } });
If needed, this is the page that it is being sent to. Currently, I am testing to make sure the AJAX is sending something.
> if($_POST['action'] === "update"){ > return json_encode($_POST['workOrderID']); > }
The variables in the AJAX are set, but I can not seem to find out what the issue is.
你应该这样做:
if($_POST['action'] === "update"){
echo json_encode($_POST['workOrderID']);
}
链接地址: http://www.djcxy.com/p/55868.html
上一篇: 为什么Ajax在Firefox中返回'错误'但运行'成功'?
下一篇: Ajax正在返回空字符串