javascript - build a post data structure from form with multiple variables -
i have form:
<div class="form_style"> <input name="name" type="text" id="name" class="input username" placeholder="username" /> <textarea name="content_txt" id="contenttext" cols="45" rows="5" placeholder="enter text"></textarea> <input name="event_id" id="eventid" type="hidden" value="31"/> <button id="formsubmit">add comment</button> <img src="images/loading.gif" id="loadingimage" style="display:none" /> </div>
i can post content_txt ajax php, data structure. how build data, variables?
heres ajax code content txt:
ar mydata = 'content_txt='+ $("#contenttext").val(); //build post data structure
so wish pass 2 input (name, , event_id, testing yet.)
and wish insert data sql database.
everything working, content_txt textarea. idea how add other content varmydata
?
post data json structure:
var mydata = { content_text: $('#contenttext').val(), name: $('#name').val(), event_id: $('#eventid').val() }; $.post('http://www.example.com', mydata);
Comments
Post a Comment