Reputation: 6540
I have form which data will be sent via ajax. It is normal string-type content from textarea. But i don't know how can i tell jquery that i want sent this words as data
.
$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType
});
Could someone can give me any tips?
Upvotes: 0
Views: 121
Reputation: 196306
You can use the .serialize()
docs method
$.ajax({
type: 'POST',
url: url,
data: $("#YourFormIdHere").serialize(),
success: success,
dataType: dataType
});
Upvotes: 1
Reputation: 15580
If your text area has an id:
<textarea id="myText"></textarea>
then you would send it like this:
$.ajax({
type: 'POST',
url: url,
data: "data="+$('#myText').val(),
success: success,
dataType: dataType
});
Upvotes: 0
Reputation: 16809
data = $("#my-text-area").val()
or maybe I misunderstood your question...
Upvotes: 1
Reputation: 50982
var data = $("form").serialize();
$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType
});
Upvotes: 5