我有這樣的表單;如何從HTML表單獲取輸入並查找數據?
<div id="employeeinfo" style="padding:40px" class="employee-body">
<form id="employeeform" title="" method="post">
<label class="title">First Name</label>
<input type="text" id="fname" name="first_name" >
<label class="title">Last Name</label>
<input type="text" id="lname" name="last_name" >
<input type="submit" id="submitButton" onclick="formSubmit()" name="submitButton" value="Submit">
</form>
</div>
我有一個JSON URL: 「app.employee.com/employeedata」
我需要得到FNAME和LNAME從HTML表單,並通過上述網址的JSON搜索和
顯示它到目前爲止,我有這樣的:
<script type='text/javascript'>
function formSubmit(){
var formData = JSON.stringify($("#employeeform").serializeArray());
$.ajax({
type: "POST",
url: "serverUrl",
data: formData,
success: function(){},
dataType: "json",
contentType : "application/json"
});
}
</script>
如何執行該方法?我在shopify中這樣做。
希望這將幫助你很多? @zydexo – lalithkumar
如果合適,請點擊勾號接受答案。 @zydexo – lalithkumar