I need to send a div element's inner HTML to server through post request.
What I tired using javascript is, Created a hidden input element and tried to assign the div's inner HTML in it and submitted it to the server. Since the inner HTML has single, double quotes it is not properly assigned to the value of input element.
Kindly suggest best solutions.
I need to send a div element's inner HTML to server through post request.
What I tired using javascript is, Created a hidden input element and tried to assign the div's inner HTML in it and submitted it to the server. Since the inner HTML has single, double quotes it is not properly assigned to the value of input element.
Kindly suggest best solutions.
Share Improve this question asked Jun 14, 2013 at 9:20 krishnakrishna 8372 gold badges11 silver badges19 bronze badges 1-
try to store in
textarea
– Ivan Chernykh Commented Jun 14, 2013 at 9:22
1 Answer
Reset to default 5You can use urlencode(str)
and urldecode(str)
function or you can refer
https://developer.mozilla/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FencodeURIComponent
https://developer.mozilla/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FdecodeURIComponent