Digger Posted December 14, 2023 Share Posted December 14, 2023 0 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 Quote Link to comment Share on other sites More sharing options...
requinix Posted December 14, 2023 Share Posted December 14, 2023 Commas? You mean the quotes? No, they don't matter, you don't have to remove them. The object is fine. Are you sure the JSON your PHP script is returning was decoded as JSON and isn't being kept as text? Is your script returning the right Content-Type header? Quote Link to comment Share on other sites More sharing options...
Solution Digger Posted December 14, 2023 Author Solution Share Posted December 14, 2023 Sorted it Toast.fire(JSON.parse(data)); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.