before you call Ajax, you can write the data through JavaScript, and then you can get the data in it. Send out, so cool!
> -- w -->www.php100.com
client code below. On getXML ()
{
setcookie ($('name').Value, $('val').Value);
oDiv = document.all.m
xh.send (false);
}
function. T; sorry, the loading data failed. Cause:.Quot, xh.statusText
}
}
//author: PHP100 Chinese network www.php100.com
function setcookie. SetTime (d.getTime () cookieexp);
expires =.Quot; expires=.quot; d.toGMTString ().Quot;.Quot;
document.cookie. Examples:.Lt; br/.gt;
.lt; form name=myform.gt;
name:.lt; input id=name value=.quot; variable names can even be Chinese.Quot; Uot; send out data.Quot;.Gt; phperz~com
.lt; input onclick=.quot; if (XH.Amp;.Amp; xh.responseText). N onclick=.quot; alert (document.cookie).Quot; value= display local COOKIE.gt;
.lt; /form.gt; [/code]
.Gt; [/code]
phperz~com
first. .
Third, using UTF-8 to send data will not be garbled, is the background program does not correct decoding will appear garbled.
Fourth, when Ajax sends data, if Content-Type is modified to application/x-www-form-urlencoded.quot; it must be post, and "too much data often goes wrong" is caused by sending data in GET.
fifth. Functions written in VBScript are used to transform data into GBK encoding (the default encoding of the operating system). If it is coded in Big5 on the traditional system, rather than GB2312, the number of coded characters between them is about 3 times.
sixth, using cookie to send data, one is easy to overflow, and the two is to stop wiping the butt, otherwise the data inside the cookie will be sent in every HTTP request (including pictures and script requests). Three when there are several HTTP requests concurrently, there is no way to specify that the cookie is sent to the HTTP request.
when using AJAX to return a page to GET, the Chinese in the RESPONSETEXT will appear most of the chaotic code. This is because xmlhttp has coded the resposeBody in the decoding test when it handles the returned responseText, and the Chinese character will be displayed correctly when the server is actually sending out the data flow of UTF-8. When the GBK coded stream was sent, it was a mess. The solution is to add a HEADER to the stream sent to indicate what code stream is sent, so that XMLHTTP will not be fooled. Phperz.com
PHP:header ('Content-Type:text/html; charset=GB2312');
ASP:Response.Charset (.Quot; GB2312.quot;)
JSP:response.setHeader.