开发者

String replace in var with jQuery

I am having trouble trying to get all my form data and break it down for debugging. I just want to replace the "&" with a new line.

var formData = $("#customer_detail开发者_Go百科s_form").serialize();  
var debugData = formData.text().replace(/&/g,'\n');

Thanks


jQuery's .serialize() method returns a String, not a jQuery object, so get rid of .text().

var formData = $("#customer_details_form").serialize();  
var debugData = formData.replace(/&/g,'\n');


The variable formData has the string, so text() shouldn't be necessary.
Try formData.replace(/&/g,'\n');.


formData is an ordinary string.
Remove the .text() call.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜