I know this has probably been asked a dozen times, but I am kind of stumped.
I have a form:
<form id="login">
<label>Email</label>
<input id="email"/>
<label>First Name</label>
<input id="fName"/>
<label>Last Na开发者_C百科me</label>
<input id="lName"/>
<label>Phone #</label>
<input id="phone"/>
And the ReST call I am using is:
<script type="text/javascript">
$.ajax({
url: 'http://example.com/',
type: 'PUT',
data: 'ID=1&fname=datagoeshere&lname=datagoeshere&email=datagoeshere',
success: function() { alert('PUT completed'); }
});
</script>
I guess the part I am stuck on is how to pull out just fname,lname and email and stick the information that gets entered into the form into the ReST call. The form is also posting to another form.
Replace:
'ID=1&fname=datagoeshere&lname=datagoeshere&email=datagoeshere'
with
{ ID: 1, fname: $('#fname').val(), lname: $('#lanme').val(), email: $('#email').val() }
jQuery's ajax data property takes an object and will format that object into the proper string for you.
精彩评论