[英]jquery deferred object callback not firing
我有以下代码
function get_hash(){
id = $('#file_id').val()
deferred = $.ajax({ url: "/rest/hash_upload/", type: "GET", data: {file_id: id} })
$.when(deferred).then(function(data){
alert('executing')
$('#input_md5_checksum').val(data)
})
}
Ajax被调用,我的后端按预期返回哈希值。 但是,延迟的回调方法不会触发。 谁能看到我在做什么错?
谢谢。
为什么将查询设置为变量,然后使用when()
,为什么不只使用常规的ajax调用呢?
$.ajax({
url: "/rest/hash_upload/",
type: "GET",
data: {file_id: id}
}).done(function(data){
alert('executing');
$('#input_md5_checksum').val(data);
}).fail(function(xhr, status, error){
return ("Ajax failed: " + xhr.responseText);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.