2

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_details_form").serialize();  
var debugData = formData.text().replace(/&/g,'\n');

Thanks

3 Answers 3

4

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');
Sign up to request clarification or add additional context in comments.

Comments

2

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

1 Comment

Thanks for the reply I tried that and didnt work so I looked a little harder. I had vars debugData and debug_data. lol thanks again!
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.