I’m trying to POST some json to a web service that accepts json.
The function ‘basistech.serializeOptions()’ return a Javascript object at the moment, but
I could easily make is return a string. Note that even though I’ve set the ‘accepts’ option,
the header sent is ‘Accept: undefined’, which leads to some failures on the server side.
Why can’t I give a proper mime type in ‘accepts’?
$.ajax({
url : basistech.processText_url,
accepts : "application/json",
contentType : "application/json",
dataType : "json",
data : basistech.serializeOptions(),
type : "POST",
success : function(data) {
/* whatever */
},
error : function(jqXHR, textStatus, errorThrown) {
$("#submit-button").busy("hide");
alert(textStatus);
}
});
POST /r4dws/services/doc/processText HTTP/1.1
Host: localhost:15000
Connection: keep-alive
Content-Length: 1679
Origin: http://localhost:15000
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
Content-Type: application/json
Accept: undefined
Referer: http://localhost:15000/r4dws/demo/xmltextbox.jsp
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: JSESSIONID=AB76A77DF6906229D281A931D7D10C3C
Request Payload
(messed up)
Try like this….,