Reputation: 1535
I was trying to submit a form using ajax post and server was giving me 403 error(working fine with get). Later when I encoded my 'URL', it worked fine.
What I can not understand is if I use method post then form data is going in the body of http packet. Then, what difference it makes if I encode my URL ? Why server is treating un-encoded URL acccess by POST as injection ?
var uri = encodeURI($('#registrationForm').attr('action'));
// 403 error if i do not use encodeURI, everything else same
console.log(dataString);
$.ajax({
type:"POST",
url:uri,
data:dataString,
success:function(result){
console.log(result);
},
error:function(error){
alert(error);
}
});
Upvotes: 1
Views: 420
Reputation: 127
What php framework(MVC) if you are using framework? and another what HTTP server (apache or nginx) as 403 Forbidden HTTP status code, and 403 is something to do with permission you dont have a permission to access the pages.
Instead of
$.ajax({type:"POST",url:uri,data:{ ...
try change to
$.ajax({type:"PUT",url:uri,data:{ ..
Upvotes: 1