aliento Posted May 31, 2009 Share Posted May 31, 2009 Hi! I am posting html source through POST with ajax. But when into the source i post appears the symbol & it recognize it as variable separator and doesnt load all the html source. ajax : function preview(){ var http = new XMLHttpRequest(); var url = 'preview.php'; var html = document.getElementById('html_source').value; var params = 'html='+html; http.open("POST", url, true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange = function() { if(http.readyState == 4 && http.status == 200) { Shadowbox.open({ content: 'temp/preview.htm', player: 'iframe', title: 'Preview', height: 600, width: 800, options: {} }); }; } http.send(params); } If it finds & it load all the string after as another variable. I think this is generic problem. Is there any solution? Thank you Quote Link to comment Share on other sites More sharing options...
anupamsaha Posted May 31, 2009 Share Posted May 31, 2009 Change: var params = 'html='+html; To: var params = 'html='+escape(html); Quote Link to comment Share on other sites More sharing options...
aliento Posted May 31, 2009 Author Share Posted May 31, 2009 thanks you but it still doesnt work. Quote Link to comment Share on other sites More sharing options...
aliento Posted May 31, 2009 Author Share Posted May 31, 2009 The problem now is that it doesnt parse utf-8 characters (Greek) Quote Link to comment Share on other sites More sharing options...
aliento Posted May 31, 2009 Author Share Posted May 31, 2009 Great with your guidenes i found this s encodeURIComponent(html) which is for UTF-8. Thank you Quote Link to comment Share on other sites More sharing options...
anupamsaha Posted May 31, 2009 Share Posted May 31, 2009 Great with your guidenes i found this s encodeURIComponent(html) which is for UTF-8. Thank you Yes. Also, read this: http://www.dangrossman.info/2007/05/25/handling-utf-8-in-javascript-php-and-non-utf8-databases/ This will answer your query. Cheers! 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.