I have this code (below).
$.ajax ({ type: "POST", url: "../WebServices/Feedback.svc/sendfeedback", dataType: 'json', async: false, data: '{"stars": "' + stars + '", "rating" : "' + rating + '", "note" : "' + encodeURIComponent(note) + '", "code" : "' + code + '", "permission" : "' + permission + '"}', contentType: "application/json; charset=utf-8" });
I use this to transfer data to a web service, but the problem is if there are any characters (, / ?: @ and = + $ #). I put in an encodeURIComponent that works fine, and then in the web service I put them back.
What I ask is, is there a better way to do this? It seems a little crazy that I have to encode a string every time before passing it.
thanks
jquery ajax uri character-encoding
tmutton
source share