javascript - get jQuery form - text value by id -
i have simple html jquery form , , want to: 1) value js var . 2)send json server . here form :
<div data-role="main" class="ui-content"> <data=role "form" name="seekerform" id="jobseekerform" > <label for="basic">first name :</label> <input type="text" name="seekername" id="wfirstname" data-mini="true" /> <label for="basic">last name :</label> <input type="text" name="seekerlast" id="wlastname" data-mini="true" /> <label for="basic" id="wemail">e-mail:</label> <input type="text" name="seekeremail" id="wemail" data-mini="true" /> <div data-role="fieldcontain" > <label for="select-choice-1" class="select" >choose field:</label> <select name="select-choice-1" id="selectfield" > <option value="hi-tec">software programming</option> <option value="webpro">web programming</option> <option value="qa">qa</option> <option value="systeminfo">system information</option> <option value="db">dba</option> <option value="java">java</option> <option value="c">c++</option> <option value="pyt">pyton</option> </select> </div> <div data-role="fieldcontain" > <label for="select-choice-1" class="select" >choose experience level:</label> <select name="select-choice-1" id="selectpro" > <option value="junior">junior(0-2)</option> <option value="senior">senior(2-5)</option> <option value="exp">expert(5-10)</option> </select> </div> </form> 3) same thing option value . here way im sending :
// object want send :
var jobsdata = { name: $name.val(), lname: $wlastname.val(), mail: $wemail.val(), userlocation: location, field : $selectfield.val(), pro: $selectpro.val(), range: $sliderrange.val() }; // ajax - data: how want send $.ajax({ type: 'get', datatype: 'json', url:'http://localhost:8888', data: jobsdata, success: function(jobs){ $.each(jobs,function(i,job){ $('.jobres').html(jobs); });
you can use .serialize() form values , send them server via ajax. do:
$(function() { $('form').on('submit', function( e ) { e.preventdefault(); $.ajax( url:'http://localhost:8888/', data: $(this).serialize(), ..... ); }); }); your page must running on same localhost same port 8888 work.
Comments
Post a Comment