views:

169

answers:

1

I have a form in a webpage, where the user can enter any arbitrary html. Once he clicks submit, I am sending the content to the webserver via AJAX using jQuery.post().

But for certain HTML, I am getting this response from the server

HTTP/1.0 400 Bad Request 
Content-Type: text/plain
Date: Mon, 26 Oct 2009 05:28:00 GMT

BAD REQUEST: Bad percent-encoding.

I tried changing post to get, but still facing the same issue. Does anybody know what is causing the issue and please let me know how to fix it. Thanks!

EDIT:

I guess it seems to be more of an issue with the server rather then with jQuery. Earlier I was using nanoHTTPD server and it was giving me BAD REQUEST as response. I tried to send the same request to Apache and it seems to work.

+1  A: 

How are you sending the data across?

Try sending it as a JSON object if you're not already.

var textObj = {text: $("#myTextarea").val()};

$.ajax({
    type: "POST",
    url: "example.php",
    data: textObj,
    dataType: "html"
 });
Mike Trpcic
Yeah I was sending it as JSON object. As I have mentioned in the question, it seems to be more of an issue with the server rather than jQuery. Anyways thanks for your reply.
Sudar