I have form inputs in a table row, which I would like to submit via ajax.
$(this).closest("tr").find("input,select,textarea").each(function(){$data+=$(this).attr('name')+'='+encodeURIComponent($(this).val())+'&';
I had everything working fine - until one of the inputs had an ampersand in the value. I found some information on this post, which helped a lot - and using encodeURIComponent (as shown above) I was able to get the form to submit without a problem. My question is - in that post, @T.J. Crowder mentioned how he would "strongly recommend" using @Darin Dimitrov's solution:
data: { id: thisId, value: thisValue }
How would I implement this in my current code? Also - is there any benefit to using the second code, or is encodeURIComponent just as good?