I am trying to pass array results from a php submission form back to jquery i can trigger a success or fail message using toast.
i am using
$ret["icon"] = "success";
$ret["title"] = "Request Deleted Successfully";
echo json_encode($ret);
this is the result
{"icon":"success","title":"Request Deleted Successfully"}
but to trigget the toast object i need
Toast.fire({icon: 'success',title: 'Request Deleted Successfully.'})
Looking at the different i only need to remove the commas from the array key but i dont know how to do this in jquery or javascript
Can anyone please help
2
Answers
That worked great thanks
You receive a JSON string and need to convert it to an object.
With sending the correct header from PHP (before any other output)
you should directly receive an object from jQuery without need to parse it.