I’m having a problem with IE (I’m testing in IE9, but I believe it will behave the same way in the previous versions as well).
The response I’m sending from PHP is as follow:
{"success":true,"content":"<img src=\"\/media\/page\/1528484482.jpg\" width=\"140\" height=\"140\" alt=\"1528484482.jpg\" \/>"}
It works absolutely fine in Firefox, Chrome, Safari, Opera etc. – but it doesn’t work in IE.
The response is an empty object.
When I change the response to the following it works fine – the only difference is the forward slash before the closing of the img tag:
{"success":true,"content":"<img src=\"\/media\/page\/1528484482.jpg\" width=\"140\" height=\"140\" alt=\"1528484482.jpg\">"}
Is there any way of parsing the ‘content’ response so that it doesn’t break in IE?
(This is an advice, more than a solution)
Separate presentation layers (js/html [how]) and the domain layers (php [what]).
Domain layer decides what data to return.
Presentation layer decides how the data will be presented.
Return the image path, and make the presentation layer decide how to show the image to the user.
Now the solution of your problem would be on the declaration of the doctype.
I suppose the problem is for not declaring the doctype and IE is taking XHMTL as its default doctype.
In XHTML the tag must be properly closed.
http://www.w3schools.com/tags/tag_img.asp
The rest of the browsers takes HTML5, i suppose, and it doesn’t require a closing tag on the image.