0

I have a very long string variable(2000+ characters) in JavaScript and I need to pass it to a Php page so that I can store it in a Database. Which would be The BEST technique to pass this string variable along with some other data from JavaScript to a Php page ?

3
  • Do you have a guess for what the average and max sizes would be? 4,000 bytes? 4,000,000,000 bytes? Is this a string or binary data? Commented Nov 7, 2012 at 5:59
  • BEST? Dunno, probably JSON + AJAX I'd say... Commented Nov 7, 2012 at 5:59
  • just Sting but 2000+ characters. Commented Nov 7, 2012 at 6:00

3 Answers 3

5

If you are using Ajax, try posting the data. The encoding is automatic and there is no size limit.

Sign up to request clarification or add additional context in comments.

Comments

3
$.post('/my/url.php', { 'big': 'aoeuaoeuaoeuaoeuaoeu' } );

Of course the contents of the big variable will be much bigger. 2000 characters isn't that much. I've posted at least that much with no problem.

Comments

2

i dont know much but i suggest that using json_encode() you can do it.

1 Comment

OP wants to send data from javascript to php, not the other way round.

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.