简体   繁体   中英

Post a string contains html tags in javascript

I want post a string to html file using ajax.

xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null)
  {
   alert ("Your browser does not support Ajax HTTP");
   return;
  }
    xmlhttp.onreadystatechange=getOutput;
    xmlhttp.open("GET",url,true);
    xmlhttp.send();
}

In the url I sent the parameters what i want in the another file. It also contains a string with html tags like this

<table id='detReportTable' style='color:#333333;font-family:sans-serif;width:97%;margin-left:10px;'><tbody><tr><td colspan='2' style='text-align:center;'><div style='font-size: 19px;font-weight: bold;' id='score_cont'></div></td></tr></tbody></table>

I sent this string as parameter but it does not get this parameter other parameters without having html tags will send eg: foo=sample . It shows me a error. Can i send this html string or my way is wrong please suggest any idea.

Thanks in Advance.

why not just pass all that info normally? Why do you need to include the html tags??

Your codes breaking because of the equals(=). You could replace all equals with ~, then the full parameter will get passed, and on the other page u can fix it by replacing ~ back to =

example:

var parameters = " < table id='........ >";

while( parameters.indexOf('=')>=0 ){

parameters = parameters.replace('=','~');

}

you'll also need to replace #

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM