Publish data to RESTful Invalid HTTP Status Code 405

I create a method to send json data to a 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 the 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 from Chrome to POST for the web service, it worked.

Any help would be greatly appreciated, thanks.

+8
rest ajax
source share
1 answer

Not sure what you are using as a service on the other end, but this could be due to cross-domain registration. I do not like to post a link and run, but it may come in handy to you.

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

It looks like they could make it work in IE, but you had problems with other browsers. Perhaps these pair changes will help to get access to the service better.

This post explained the error and its parts well, so if the link above does not help, it can help you diagnose the problem even more.

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

ok ok last edit, I just wanted to make sure that you have enough information to hopefully solve your problem, here is a good article about the underlying problem that I think you have.

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

+11
source

All Articles