I can't get this request to do anything other than fail. I've used curl and the web developer toolbar to check the created URL, WD always says the response comes back correctly as 200. I've tried altering the content types to text, octet-stream, and commenting it out. I've also taken the JSON response and validated it using JSONLint.
The code I'm using is this;
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/testing.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" ></script>
<script type="text/javascript">
$(function(){
$("body").append("<p>Testing.....</p>");
var test= {latitude:"37.0205",longitude:"-7.969141667",startDate:"09-01-2014",endDate:"09-02-2014"};
var url="<hidden>";
$.ajax({
url : url,
type: "GET",
data : test,
dataType:"json",
contentType:"application/json",
success: function(data,status)
{
$("body").append("<p>Success"+JSON.stringify(data)+"</p>");
$("body").append("<p>Success"+status+"</p>");
},
error: function (jqXhr,textStatus,errorThrown)
{
$("body").append("<p>Failure " + JSON.stringify(jqXhr)+"----- "+ textStatus+ "----- "+ errorThrown+"</p>");
}
});
$("body").append("<p>input"+JSON.stringify(test)+"</p>");
});
</script>
</head>
<body>
<h1>Weather test</h1>
</body>
</html>
The output in my web browser from the error function is "Failure {"readyState":0,"responseText":"","status":0,"statusText":"error"}----- error----- "
The header is of the form,
HTTP/1.1 200 OK Cache-Control: private, max-age=0 Server: Microsoft-IIS/7.5 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Fri, 03 Oct 2014 11:57:47 GMT Content-Length: 25328
and was taken using a curl -ivs --raw to the url with all appropriate get parameters. The valid JSON followed directly after this. I'm worried that not having a content type might be throwing this.
I know there are a lot of other questions like this, but I've tried to go through them first and apply the lessons learnt. If you've any other suggestions, I would be very grateful.
Thanks,