jquery.form的ajaxsubmit一问
做一个html页面,提交后只弹出showRequest函数里的消息,没有showResponse里的消息
代码:
<form id="form1" name="form1" method="post" action="">
<input type="text" name="textfield" id="textfield" />
<input type="submit" name="button" id="button" value="提交" />
</form>
<span id="retext"></span>
<script>
$(document).ready(function() {
var options = {
target: 'retext',
url: 'http://localhost/user.htm?login',//直接访问这地址,有返回值。。换其他地址也不行
beforeSubmit: showRequest,
success: showResponse
};
$("#form1").submit(function() {
$(this).ajaxSubmit(options);
return false;
});
});
function showRequest(formData, jqForm, options) {
var queryString = $.param(formData);
alert('About to submit: \n\n' + queryString);
return true;
}
function showResponse(responseText, statusText) {
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
'\n\nThe output div should have already been updated with the responseText.');
}
</script>