AngularJS JSON Data Returns Backspaces On My HTML
- Forums
- AngularJS
- AngularJS JSON Data Returns Backspaces On My HTML
the problem described in this forum topic is about developers getting back slashes on their JSON data callback when using AngularJS [4576], Last Updated: Mon Jun 24, 2024
webune support
Thu Oct 08, 2015
0 Comments
476 Visits
this is my case. i had an app which i was using to get data from my database using php and mysql which i mascaraed with jason file. one of the objects in the array contained HTML data. for example:this is how my object looked like. let me give you an example i was using, i was using this example: https://docs.angularjs.org/api/ng/service/$sce which takes me to http://plnkr.co/edit/?p=preview&s=fnZKnwdsetpar24W
on this plnkr contains a file called test_data.json,
"htmlComment": "<i>Yes!</i> Am I the only other one?"
but when i got the JSON back, it looked like this:
"htmlComment": "<i>Yes!<\\/i> Am I the only other one?"
my solution, i need to add the header:
header("Content-Type: application/json; charset=UTF-8");
hope that helps