$("#login").click(function() {
var mydata = $("#loginform").serialize();
$.post("http://events.rate-mate.com:5000/auth", {
data: mydata
}, function(response) {
$("#result").html(response);
}, "json");
});
它不发送任何参数,也没有响应。
答案 0 :(得分:0)
请参阅以下示例,了解通过ajax post
//callback handler for form submit
$("#loginform").submit(function(e) {
var postData = $(this).serializeArray();
var formURL = $(this).attr("action");
$.ajax({
url: formURL,
type: "POST",
data: postData,
success: function(data, textStatus, jqXHR) {
//data: return data from server
},
error: function(jqXHR, textStatus, errorThrown) {
//if fails
}
});
e.preventDefault(); //STOP default action
e.unbind(); //unbind. to stop multiple form submit.
});
$("#loginform").submit(); //Submit the FORM

<form name="loginform" id="loginform" action="sample_url.php" method="POST">
First Name:
<input type="text" name="fname" value="" />
<br/>Last Name:
<input type="text" name="lname" value="" />
<br/>Email :
<input type="text" name="email" value="" />
<br/>
</form>
&#13;