我创建了一个方法将json数据发布到Web服务:
function WishList() { }
WishList.prototype.addToWishList = function(redirectURL, postURL, userObj) {
$.ajax({
type: "POST",
url: postURL,
data: JSON.stringify(userObj),
dataType: 'json',
contentType: "application/json",
success: function(data){alert(data);},
failure: function(errMsg) {
alert(errMsg);
}
}
This is my object:
var user1 = {
ID:1,
Sex:1,
Name:"titi",
Company:"ABC",
Address:"Phnom Penh",
Email:"test.abc@gmail.com",
Phone:"011123456",
WebAccount:"test.abc@gmail.com",
Password:"123456",
GroupCustomerID:125,
Stars:1,
IsVIP:0,
PriceLevel:1,
LastDateSale:"\/Date(-62135596800000)\/",
TotalCredit:150.12,
AgingData:null,
TotalRedeemPoint:1000.00,
RedeemData:null,
ExchangeRate:155.00,
HistoryData:null
};
Calling function :
$(document).ready(function () {
var myWishList = new WishList();
$('#addToWishList').click(function(){
myWishList.addToWishList('http://www.blahblahblah.com' , 'http://blahblah/Website/Products/Product.svc/Wishlist/' , user1);
});
});
Run Code Online (Sandbox Code Playgroud)
然后我在我的控制台中出错:
"NetworkError: 405 Method Not Allowedin in firefox和Invalid HTTP status code 405 , XMLHttpRequest cannot load urlin chrome.
注意:当我使用Rest ClientChrome POST进行网络服务时,它可以正常运行.
非常感谢任何帮助,谢谢.
Ton*_*ony 11
不确定您在另一端使用什么作为服务,但这可能是由于跨域发布.我讨厌发布一个链接并运行但这可能对你有用.
http://praneeth4victory.wordpress.com/2011/09/29/405-method-not-allowed/
看起来他们可以在IE中使用它,但与其他浏览器一样有一些问题.也许这些改变将有助于更好地访问服务.
这篇文章很擅长解释错误及其中的部分,所以如果上述链接没有帮助,这个可能会帮助您进一步诊断问题.
http://www.checkupdown.com/status/E405.html
好的最后编辑,只是想确保你有足够的信息,希望能够解决你的问题,这是一篇关于潜在问题的好文章,我相信你有...
http://www.d-mueller.de/blog/cross-domain-ajax-guide/
| 归档时间: |
|
| 查看次数: |
26452 次 |
| 最近记录: |