Javascript 应用程序JQuery错误:初始化前无法调用对话框上的方法;试图调用方法';打开';

Javascript 应用程序JQuery错误:初始化前无法调用对话框上的方法;试图调用方法';打开';,javascript,html,jquery,Javascript,Html,Jquery,我试图在我的应用程序中添加一个对话框,但出现上述错误 我的jQuery代码: $( "#dialog" ).dialog({ autoOpen: false, width: 450, modal: true, buttons: { "Save": function() { $("#newSup").submit

我试图在我的应用程序中添加一个对话框,但出现上述错误

我的jQuery代码:

    $( "#dialog" ).dialog({
        autoOpen: false,
        width: 450,
        modal: true,
        buttons: {
            "Save": function() {
                $("#newSup").submit();
            }
        }});

    $( ".addsupButton" ).click(function() {
        $("#newSup table").remove();


         $("#newSup").append(
            "<table style='margin-left: auto; margin-right:auto; background-color: #ffffff;' id='edittable'>"+
                "<tr>"+
                    "<td>Supplier ID</td>"+
                    "<td style='padding-left: 6px;'><input type='text' name='new_supplier_id' id='new_supplier_id' value='' /></td>"+
                "</tr>"+
                "<tr>"+
                    "<td>Customer ID</td>"+
                    "<td><input type='text' name='custID' id='custID' value='' /></td>"+
                "</tr>"+
                "<tr>"+
                    "<td>Forecast Sales</td>"+
                    "<td><input type='text' name='forecastSales' id='forecastSales' value='' /></td>"+
                "</tr>"+
                "<tr>"+
                    "<td>Forecast Percentage</td>"+
                    "<td><input type='text' name='forecastPercentage' id='forecastPercentage' value='' /></td>"+
                "</tr>"+
                    "<td><input type='form' name='addform2' id='addform2' style='visibility: hidden;' /></td>"+
                "</tr>"+
            "</table>"      
        ); 
        $("#dialog").dialog( "open" );
    });
});
$(“#dialog”).dialog({
自动打开:错误,
宽度:450,
莫代尔:是的,
按钮:{
“保存”:函数(){
$(“#新闻报道”).submit();
}
}});
$(“.addsupButton”)。单击(函数(){
$(“#newSup表”).remove();
$(“#新闻报道”).append(
""+
""+
“供应商ID”+
""+
""+
""+
“客户ID”+
""+
""+
""+
“预测销售额”+
""+
""+
""+
“预测百分比”+
""+
""+
""+
""+
""      
); 
$(“对话框”)。对话框(“打开”);
});
});
HTML div和表单:

<div class='dialog' id='dialog' title='New Supplier'>
  <form method='POST' id ='newSup' name = 'newSup' action='".$_SERVER['PHP_SELF']."' 
  enctype='multipart/form-data'></form>
</div>

初始化jQuery的按钮:

<button class='addsupButton' id='button' type='button' name='addRow'>Add Supplier</button>
添加供应商

非常感谢您的帮助。

您的错误在额外的右括号中-
})
$(#对话框)之后。对话框(“打开”)

$(“#dialog”).dialog({
自动打开:错误,
宽度:450,
莫代尔:是的,
按钮:{
“保存”:函数(){
$(“#新闻报道”).submit();
}
}});
$(“.addsupButton”)。单击(函数(){
$(“#newSup表”).remove();
$(“#新闻报道”).append(
""+
""+
“供应商ID”+
""+
""+
""+
“客户ID”+
""+
""+
""+
“预测销售额”+
""+
""+
""+
“预测百分比”+
""+
""+
""+
""+
""      
); 
$(“对话框”)。对话框(“打开”);
});


添加供应商
您的错误在额外的右括号中-
})
$(#对话框)之后。对话框(“打开”)

$(“#dialog”).dialog({
自动打开:错误,
宽度:450,
莫代尔:是的,
按钮:{
“保存”:函数(){
$(“#新闻报道”).submit();
}
}});
$(“.addsupButton”)。单击(函数(){
$(“#newSup表”).remove();
$(“#新闻报道”).append(
""+
""+
“供应商ID”+
""+
""+
""+
“客户ID”+
""+
""+
""+
“预测销售额”+
""+
""+
""+
“预测百分比”+
""+
""+
""+
""+
""      
); 
$(“对话框”)。对话框(“打开”);
});

添加供应商