ajax request.getremotuser,JQuery Ajax POST request to remote web service

I somehow can't figure it out, the situation is as follows:

I'm calling a method on a web service that is not on the same machine and use the following JS snippet in my script:

$.ajax({

type: "POST",

url: "http://" + gServer + "/xawebservice/xawebservice.asmx/" + webMethod,

contentType: "application/json; charset=utf-8",

dataType: "json",

cache: false,

async: false,

data: WSParameters,

success: function callFunction(result) { processResults(result, pType, pParam1); },

error: function (xhr, status, error) {

alert(error.toString());

//alert(xhr.toString());

}

});

Parameters are fine and tested, the web method is also correct.

As an error message I get this:

Firefox: [Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://localhost:7515/jquery-1.8.3.js :: :: line 8434" data: no]

Chrome: Error: NETWORK_ERR: XMLHttpRequest Exception 101

IE8: No Transport

If I'm using the same snippet on a web service that is running on the same machine, there is no problem. And if I use the remote web service over the web interface, it's also working fine.

PS: I googled around a bit and some pages were recommending some cross domain parameters, which didn't work either. Unfortunately using a relative path will not work I guess.

Thanks for any efforts in advance.

Br

vm370

UPDATE:

Alright I updated my code to execute a CORS request based on my existing one, but I get an error 500, executing the request on the server directly is working fine and CORS is activated on the server.

function xenappRequest(pType, pParam1) {

// CORS request

var url = "http://" + gServer + "/webservice/webservice.asmx/webMethod";

var params = { "appName": pParam1 };

var xhr = createCORSRequest("POST", url);

if (!xhr) {

alert('CORS not supported');

} else {

// Do the request

// Response handlers.

xhr.onload = function () {

//var text = xhr.responseText;

alert('Response from CORS request to ' + url + ': ' + xhr.response);

};

xhr.onerror = function () {

alert('Woops, there was an error making the request.');

};

xhr.send(JSON.stringify(params));

}

}

function createCORSRequest(method, url) {

var xhr = new XMLHttpRequest();

if ("withCredentials" in xhr) {

// Check if the XMLHttpRequest object has a "withCredentials" property.

// "withCredentials" only exists on XMLHTTPRequest2 objects.

xhr.open(method, url, true);

} else if (typeof XDomainRequest != "undefined") {

// Otherwise, check if XDomainRequest.

// XDomainRequest only exists in IE, and is IE's way of making CORS requests.

xhr = new XDomainRequest();

xhr.open(method, url);

} else {

// Otherwise, CORS is not supported by the browser.

xhr = null;

}

return xhr;

}

From FF i get the error 500, in IE8 the request lands in the xhr.onerror clause...

Any ideas?

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)javaEE_SSH_mysql码头船只出行及配套货柜码放管理系统的设计与实现(源码+数据库sql+lun文+视频齐全)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值