I've got 2 servers with different versions of .NET installed. Server 1 has .NET 1.1 and Server 2 has .NET 3.5.
I have a webservice on the .NET 3.5 server, where the following works fine:
function selectedDateTime(strDate, strHours, strMinutes) {
$.ajax({
url: 'webservice.asmx/GetCount',
type: 'POST',
data: '{strMeetingDate: "' + strDate + ' ' + strHours + ':' + strMinutes + ':00"}',
contentType: 'application/json; charset=utf-8',
dataType: 'jsonp',
success: function(department) {
console.log("success: " + department.d);
},
error: function(xhr, status, error) {
console.log("status message: " + status);
console.log("error message: " + error);
console.log("xhr message: " + xhr.responseText);
}
});
}
$("#btnTest").click(function(event) {
selectedDateTime("01/07/2013", "13", "00");
});
I want to use the same script on the older .NET 1.1 server too, but can't move the webservice to the old server because it's written using .NET 3.5, so when I tried and it just gave lots of error messages.
So I thought I should just move the html/javascript above to the old server and tell it to point to the webservice on the new server:
I did, and changed the script above a little to point to the new server:
url: 'http://server2/webservice.asmx/GetCount',
It gave the following message:
http://server2/webservice.asmx/GetDayCount 401 (Unauthorized)
http://server2/webservice.asmx/GetDayCount Origin http://server1 is not allowed by Access-Control-Allow-Origin.
XMLHttpRequest cannot load http://server2/webservice.asmx/GetDayCount. Origin http://intranet is not allowed by Access-Control-Allow-Origin.
So I changed the script above a little again, by changing the json
bit to jsonp
, as I think jsonp allows crossdomain?
dataType: 'jsonp',
But that didn't solve the problem either, I am now getting:
GET http://server2/webservice.asmx/GetCount?callback=jQuery…2680346152&{strMeetingDate:%20%2201/07/2013%2013:00:00%22}&_=1372680346153 500 (Internal Server Error)
Anyone know why this is not working, as the webservice and script clearly worked on the new server when both files were together on the same server.