/Tag: ajax

Avoid sending Ajax request parameters in query string style

By |2011-06-29T17:36:36+00:00June 29th, 2011|Categories: Technical|Tags: , , |

While reviewing some code, I found someone calling jQuery Ajax like this: $.ajax({       type: "POST",       url: "/AddPost",       data:  "postText="+ PostText ,       dataType: "json",       success: function (status) {        }}); //$.ajax({ And as you see in the previous code, it is sending the data using this line: data: "postText="+ PostText , This is like a query string style, this will work well but image the user inserted a special char in PostText, such as ?? you will get on the server un expected value “"jQuery15107041011152323335_1309357585354"” So never use this style while dealing with Ajax calls, you need to post it in JSON [...]