views:

128

answers:

2
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 using the encodeURIComponent over the parameters. It works fine for other parameters that do not have '/' in them. Please help.

A: 

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?

jdigital
A: 

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.

srila