Hybrid View
-
29 Jan 2009 4:53 AM #1
[SOLVED] json.decode error when HTML code is in response
[SOLVED] json.decode error when HTML code is in response
Hi,
i have following problem.
the problem occurs on ajax-respones on IE6 with deactivated Active-X.
if i get a json response (header: content:type: text/html for iframe) which contains html code i get a runtime error on ie6.
breack point is the function in the core
in ff my response.responseText look likePHP Code:json.decode()
on IE6PHP Code:...{"html":"<p>Die Ergebnisliste <\/p>"}...
PHP Code:...{"html":"<p>Mein Text <\/p>"}</p>

For IE6 with deactivated Active-X i use the xmlHttpRequest Fallback solution over a iframe (http://extjs.com/forum/showthread.php?t=45402).
So my problem could be also a form upload problem with json respons.
i am happy for all hints and tips
regards
nils
-
29 Jan 2009 4:57 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
The only reliable method I know is to return a valid HTML page with a <textarea> tag with the JSON data as the value.
(but you'll need to change some code to extract the value from the textarea in the iframe)
-
29 Jan 2009 5:00 AM #3
thank you for the hint, are there already solutions on the forum?
-
30 Jan 2009 4:18 AM #4
I found following solution:
on server site
i replace double quots with single ones and then change the html tags to the htmlentities.PHP Code:$mytext = '<p><span style="font-weight: bold;">IE6</span>let me cry!</p>';
$mytext = str_replace('"','\'', $mytext);
$mytext = htmlspecialchars($mytext,ENT_QUOTES));
on client side:
here i decode the htmlentties bag to tags.PHP Code:mynamespace.HtmlPanel = Ext.extend(Ext.Panel, {
initComponent: function(){
Ext.apply(this, {
bodyStyle: 'padding: 5px'
});
mynamespace.HtmlPanel.superclass.initComponent.apply(this, arguments);
// Decode the htmlentities back to html tags
this.html = Ext.util.Format.htmlDecode(this.html);
}
});
Ext.reg('HtmlPanel',mynamespace.HtmlPanel);
to decode the singlequot i extend the decodeHtml function.
PHP Code:Ext.apply(Ext.util.Format, {
htmlDecode : function(value){
return !value ? value : String(value).replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"').replace(/&/g, "&").replace(/'/g, "'");
}
});
-
29 Nov 2012 12:18 AM #5
got same problem with JSON
got same problem with JSON
I am trying to solve it with .htaccess
any chane it can be done&


Reply With Quote