开发者

problem with '/' in the REST URL parameters for an Ajax call

var url     = relativeURI+'/rest/PPS/Prod/'+encodeURIComponent(prod)+'/Section/'+encodeURIComponent(section);

$j.ajax({
  url: url,

  type: 'POST',

  error: function(){
    alert('Error');
  },
  success: function(){
   alert('ItWorks');
  }
});

}

In this ajax call, if I have '/' in the parameters prod or sec, then there is an error. The request does not even hit the server. I am 开发者_如何学Pythonusing the encodeURIComponent over the parameters. It works fine for other parameters that do not have '/' in them. Please help.


I replicated your logic and the request does go to the server. However, if the server doesn't like the URL, then your server side code won't even get called. (In my case, there was no server side code, but I can see the 404 response and can see that the server -- Apache -- decoded the URL).

So perhaps your server can't decode the URL. Are you sure that you encoded it when you tried the non-jquery route? You might not need the encodeURIComponent calls. What happens if you remove them?


I have encoded the parameters and tried the non-jQuery route where it works fine ( Was using RESTEasy). When i remove the slashes, then I get 404 response, which means that there is no REST method with that URI.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜