发布数据的RESTful无效HTTP状态code 405 [英] Post data to RESTful Invalid HTTP status code 405

查看:307
本文介绍了发布数据的RESTful无效HTTP状态code 405的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个方法,张贴JSON数据网络服务:

 函数愿望清单(){}
 WishList.prototype.addToWishList =功能(的redirectUrl,postURL,userObj){
    $阿贾克斯({
           键入:POST,
           网址:postURL,
           数据:JSON.stringify(userObj)
           数据类型:JSON,
           的contentType:应用/ JSON
           成功:功能(数据){警报(数据);},
           失败:功能(ERRMSG){
              警报(ERRMSG);
           }
 }

 这是我的对象:

 VAR USER1 = {
            ID:1,
            性别:1,
            产品名称:蒂蒂
            公司:ABC,
            地址:金边,
            电子邮件:test.abc@gmail.com
            电话号码:011123456,
            WebAccount:test.abc@gmail.com
            密码:123456,
            GroupCustomerID:125,
            明星:1,
            IsVIP:0,
            PriceLevel:1,
            LastDateSale:\ /日期(-62135596800000)\ /,
            TotalCredit:150.12,
            AgingData:空,
            TotalRedeemPoint:1000.00,
            RedeemData:空,
            ExchangeRate:155.00,
            HistoryData:空
        };

 调用函数:

 $(文件)。就绪(函数(){
    VAR myWishList =新的愿望清单();
    $('#addToWishList)。点击(函数(){
       myWishList.addToWishList('http://www.blahblahblah.com','HTTP://blahblah/Website/Products/Product.svc/Wishlist/,用户1);
    });
 });
 

然后我得到了我的控制台错误: NetworkError:405不允许的方法火狐无效的HTTP状态code 405 ,XMLHtt prequest不能加载网址

注:当我使用 REST客户端 Chrome浏览器为 POST 来的Web服务,它的工作。

任何帮助将是非常美联社preciated,谢谢你。

解决方案

不知道你使用的是作为另一端的服务,但是这可能是由于跨域张贴。我讨厌张贴一个链接并运行,但是这可能是一些使用你。

<一个href="http://praneeth4victory.word$p$pss.com/2011/09/29/405-method-not-allowed/">http://praneeth4victory.word$p$pss.com/2011/09/29/405-method-not-allowed/

看起来他们可以得到它在IE浏览器的工作,但有一些问题,你用其他浏览器。也许这些情侣变化将有助于访问服务更好。

这个职位是善于解释错误和零部件把它作为,因此,如果上面的链接是没有帮助的这一个可以帮助你进一步诊断问题。

<一个href="http://www.checkupdown.com/status/E405.html">http://www.checkupdown.com/status/E405.html

确定确定最后的修改,只是想确保你有足够的信息,希望能够解决您的问题,这里是潜在的问题,我相信你有一个很好的文章。

<一个href="http://www.d-mueller.de/blog/cross-domain-ajax-guide/">http://www.d-mueller.de/blog/cross-domain-ajax-guide/

I create a method to post json data to web service :

 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);
    });
 });

Then I got errors in my console : "NetworkError: 405 Method Not Allowed in firefox and Invalid HTTP status code 405 , XMLHttpRequest cannot load url in chrome.

Note: When I use Rest Client of Chrome to POST to web service, it worked.

Any help would be much appreciated, thank you.

解决方案

Not sure what you are using as the service on the other end but this may be due to cross domain posting. I hate to post a link and run but this may be of some use to you.

http://praneeth4victory.wordpress.com/2011/09/29/405-method-not-allowed/

Looks like they could get it working in IE but had some issues as you with the other browsers. Perhaps these couple changes will help access the service better.

This post was good at explaining the error and parts to it as well so if the above link is not helpful this one may help you diagnose the issue further.

http://www.checkupdown.com/status/E405.html

ok ok last edit, just wanted to make sure you have enough info to hopefully resolve your issue, here is a good article on the underlying problem I believe you are having..

http://www.d-mueller.de/blog/cross-domain-ajax-guide/

这篇关于发布数据的RESTful无效HTTP状态code 405的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆