patrick wrote:
A quick simple question... given the following js code

if (window.XMLHttpRequest){
        var xhr = new XMLHttpRequest();
} else {
    ... IE stuff....
}

var params = "key=value&  etc...";

xhr.open("POST", formUrl, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-
urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(params);

Are the params good to go or should they be escaped for POST method?
e.g.
var params = "key="+ escape(value) +"&  etc...";

The choosen content type (e.g. application/x-www-form-
urlencoded) requires encoding, with ECMAScript/Javascript I think using
                       encodeURIComponent(value)
is more suitable than
                       escape(value)

http://en.wikipedia.org/wiki/Percent-encoding#The_application.2Fx-www-form-urlencoded_type



--

        Martin Honnen --- MVP Data Platform Development
        http://msmvps.com/blogs/martin_honnen/

--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to