Why does this call to jQuery's $.ajax() fire an empty request in Chrome and Firefox?
Posted
by Martin Wiboe
on Stack Overflow
See other posts from Stack Overflow
or by Martin Wiboe
Published on 2010-03-15T10:41:51Z
Indexed on
2010/03/15
10:49 UTC
Read the original article
Hit count: 649
Hello,
I am trying to call a WCF RESTful service from jQuery. I am using JSON to encode both request and response.
The following code functions correctly in IE8:
url = 'http://ipv4.fiddler:5683/WeatherWCF/NewBinding/MyService/GetValueFloat';
$.ajax({
url: url,
data: '{"alias": "Udetemperatur"}',
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "text", // not "json" we'll parse
success:
function(res) {
alert('Received response: ' + res);
}
});
However, in both Firefox and Chrome, res contains an empty string. After using Fiddler to monitor the request, it appears that jQuery sends an empty request to the server as shown in this screen dump: http://imgur.com/EJgwS.png
This is the successful request: http://imgur.com/S77BA.png
What am I doing wrong?
Kind regards,
Martin
© Stack Overflow or respective owner