Jump to content

[SOLVED] POST data with ajax. But this & stops the data


aliento

Recommended Posts

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

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!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.