'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.
Solution 1:[1]
You should do this bro :
if($_POST['action'] === "update"){
echo json_encode($_POST['workOrderID']);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Olvis Quintana |
