Javascript 在提交jquery ajax帖子时加载条,don';我没有出现
我正在使用 所有这些都很好,但我发送了一篇ajax帖子,因此我添加了以下代码:Javascript 在提交jquery ajax帖子时加载条,don';我没有出现,javascript,jquery,ajax,forms,loading,Javascript,Jquery,Ajax,Forms,Loading,我正在使用 所有这些都很好,但我发送了一篇ajax帖子,因此我添加了以下代码: $( "#dialog-form" ).dialog({ autoOpen: false, height: 500, width: 550, modal: true, buttons: { "Create an account": function() {
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 500,
width: 550,
modal: true,
buttons: {
"Create an account": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
if ( bValid ) {
$.ajax({ url: 'about.php',
data: {name: name.val(), email: email.val()},
type: 'post',
async: false
});
}
}
}
});
$('#progress')
.hide() // hide it initially
.ajaxStart(function() {
$(this).show();
})
.ajaxStop(function() {
$(this).hide();
});
我添加了$.ajax
部分。
我想在处理帖子时显示加载条,我添加了以下代码:
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 500,
width: 550,
modal: true,
buttons: {
"Create an account": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
if ( bValid ) {
$.ajax({ url: 'about.php',
data: {name: name.val(), email: email.val()},
type: 'post',
async: false
});
}
}
}
});
$('#progress')
.hide() // hide it initially
.ajaxStart(function() {
$(this).show();
})
.ajaxStop(function() {
$(this).hide();
});
但它不起作用,我的帖子转到了一个php脚本,其中一个有2秒的等待时间。
它只是不显示#progress div
,因此.hide
正在工作
另外,例如,如果我添加$(“#对话框窗体”).dialog({hide:“slide”})
在$.ajax
不起作用之前,它会在所有按钮功能完成后隐藏
谢谢。如果您的#progress div
仅在本次ajax调用中显示,为什么不将显示
/隐藏
操作放在按钮操作上
像这样:
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 500,
width: 550,
modal: true,
buttons: {
"Create an account": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
if ( bValid ) {
// show before ajax call
$('#progress').show();
$.ajax({ url: 'about.php',
data: {name: name.val(), email: email.val()},
type: 'post',
async: true,
complete: function() {
//hide on complete
$('#progress').hide();
}
});
}
}
}
});
希望这会有所帮助。如果您的#progress div
仅在本次ajax调用中显示,为什么不将显示
/隐藏
操作放在按钮操作上
像这样:
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 500,
width: 550,
modal: true,
buttons: {
"Create an account": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
if ( bValid ) {
// show before ajax call
$('#progress').show();
$.ajax({ url: 'about.php',
data: {name: name.val(), email: email.val()},
type: 'post',
async: true,
complete: function() {
//hide on complete
$('#progress').hide();
}
});
}
}
}
});
希望这会有所帮助。不起作用$(#progress').show();不要工作。无论我在ajax之前还是之后写了什么,只要在主要函数按钮上完成所有操作后,就不会工作:{“创建帐户”:function()@QuiGloriam尝试在ajax调用中将
async:false
更改为async:true
。不要工作。$('#progress').show();不工作。无论我在ajax之前或之后写什么,只要在主要函数按钮上完成所有操作之前都不工作:{“创建帐户”:function()@QuiGloriam尝试在ajax调用中将async:false
更改为async:true
。