Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

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"
 }); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top