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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -