我试图让JQuery的对话框在对话框按钮中单击“添加”按钮时将数据发送到远程脚本,但我的脚本似乎死在.ajax并且我的控制台中没有显示任何内容给我一个关于错误的线索:
$( "#button" ).dialog({
resizable: false,
title: "Confirm",
height:140,
modal: true,
autoOpen: false,
buttons: {
"Add": function() {
var data = $('.part1').serialize()
$.ajax({
url: "/www/htdocs/test.pl",
type: "GET",
data: data,
cache: false,
success: function {
$('#div1').fadeOut('slow');
$('#div2').fadeIn('slow');
}
});
return false;
},
Cancel: function() {
$(this).dialog( "close" );
}
}
});
<div id="div1">
<input class="part1" type="hidden" value="Jon" name="fname">
<input class="part1" type="hidden" value="Doe" name="lname">
<input class="part1" type="hidden" value="jon@doe.com" name="email">
<input id="button" type="button" value="button">
</div>
<div id="div2">Complete</div>
答案 0 :(得分:0)
您遇到一些语法错误(确实显示在FireBug中):
在结尾处添加;
:
var data = $('.part1').serialize()
像:
var data = $('.part1').serialize();
在()
success: function
喜欢:
success: function()
制作完整的代码:
$( "#button" ).dialog({
resizable: false,
title: "Confirm",
height:140,
modal: true,
autoOpen: false,
buttons: {
"Add": function() {
var data = $('.part1').serialize();
$.ajax({
url: "/www/htdocs/test.pl",
type: "GET",
data: data,
cache: false,
success: function()
{
$('#div1').fadeOut('slow');
$('#div2').fadeIn('slow');
}
});
return false;
},
Cancel: function() {
$(this).dialog( "close" );
}
}
});
有了这些修复,在这里工作正常: http://jsfiddle.net/YzhG9/10/