What options do I have for passing large text in a call to $.ajax(...)?
I have the content stored in a variable already:
articleText
So I have:
$.ajax(
type: "POST",
url: "/test/add_article",
dataType: "json",
data: ??????,
success: function(d) {
alert(d);
}
});
In the docs they show:
"p1=asdfasdf&p2=2sdfasdf"
Also:
data: ({someName: someValue })
I like the latter, so is the someValue where I put my variable?
What about encoding it or is it just like a form post where I can handle that on the server-side?
)
You would simply do
data: { aT: articleText }. Then in your server-side script you can access that text as post variableaT…in PHP it would be:$_POST['aT'].jQuery converts
{ aT: articleText }to"aT=myTextContentWouldBeHere".