Javascript 迁移到更高版本时,jquery提交不起作用
您好,为了使用tablesorter.js插件,我刚从jquery 1.10.2迁移到1.2.1,但我的问题是,我的jquery ajax帖子不再适用于此jquery版本,我希望有人能找出问题所在或我遗漏了什么,以下是我的代码: js文件Javascript 迁移到更高版本时,jquery提交不起作用,javascript,jquery,ajax,Javascript,Jquery,Ajax,您好,为了使用tablesorter.js插件,我刚从jquery 1.10.2迁移到1.2.1,但我的问题是,我的jquery ajax帖子不再适用于此jquery版本,我希望有人能找出问题所在或我遗漏了什么,以下是我的代码: js文件 // variable to hold request var request; // bind to the submit event of our form $("#postAtencion").submit(function(event){ //
// variable to hold request
var request;
// bind to the submit event of our form
$("#postAtencion").submit(function(event){
// abort any pending request
if (request) {
request.abort();
}
// setup some local variables
var $form = $(this);
// let's select and cache all the fields
var $inputs = $form.find("input, select, button, textarea");
// serialize the data in the form
var serializedData = $form.serialize();
// let's disable the inputs for the duration of the ajax request
$inputs.prop("disabled", true);
// fire off the request to /form.php
request = $.ajax({
url: "/admin/atencion",
type: "post",
data: serializedData,
success: function(response){
// we have the response
$('#tableSubView').html(response);
}
});
// callback handler that will be called on success
request.done(function (response, textStatus, jqXHR){
// log a message to the console
console.log("Atencion Posted");
});
// callback handler that will be called on failure
request.fail(function (jqXHR, textStatus, errorThrown){
// log the error to the console
console.error(
"The following error occured: "+
textStatus, errorThrown
);
});
// callback handler that will be called regardless
// if the request failed or succeeded
request.always(function () {
// reenable the inputs
$inputs.prop("disabled", false);
});
// prevent default posting of form
event.preventDefault();
});
Jsp文件
<div class="container">
<h2>Consulta</h2>
<form id="postAtencion" style="padding:19px;">
<div>
Number: <input type="text" name="msisdn" style="margin-left: 15px;" class="inputAtencion">
</div>
Init Date: <input type="date" name="fechaInicio" class="inputAtencion">
Final Date: <input type="date" name="fechaFin" class="inputAtencion">
<input type="submit" value="Search" class="buscar"/>
</form>
<div id="tableSubView"></div>
</div>
<script src="js/file.js"></script>
<script src="js/atencion-post.js"></script>
<script src="js/jquery-requiered.js"></script>
<script src="js/jquery.tablesorter.js"></script>
1.2.1是在2007年发布的?1.10.2到1.2.1正在倒退。嗯,真的,好吧,lol nevermind,对不起,我使用jqueryNow有点新。这是一个很好的问题,你很少看到。现在你在哪里找到了1.2.1呢?我们使用jQuery1.10.2和tablesorter很好。