我创建了一个方法将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);
});
});
然后我的控制台出错了:
“NetworkError:在Firefox中不允许405方法和无效的HTTP状态代码405,XMLHttpRequest无法在chrome中加载url.
注意:当我使用Chrome的Rest Client发布到Web服务时,它可以正常工作.
非常感谢任何帮助,谢谢.