gpt4 book ai didi

javascript - jquery post 在 firebug 中未定义

转载 作者:行者123 更新时间:2023-11-28 12:46:57 24 4
gpt4 key购买 nike

在表单中的 2 个元素上,我在 firebug 中收到“未定义”。我试图追踪错误,但一直碰壁,因此发表了这篇文章。出现错误的区域之一是 divId block ,另一个是表单中的#company。如果有人可以检查我的代码并指出我的错误,我将不胜感激。谢谢

// Function to add box

function addbox() {

$("#boxform").dialog({
autoOpen: false,
resizable: true,
modal: true,
title: 'Submit a box intake request',
width: 470,
beforeclose: function (event, ui) {
$("#addbox").html("");
$("#divId").html("");

}

});

$('#boxsubmit').click(function () {

var company = $('.company').val();
var box = $('.box').val();
var service = $('#service').val();
var authorised = $('.authorised').val();
var address = $('.address').val();
var data = 'company=' + company + '&box=' + box + '&authorised=' + authorised + '&service=' + service + '&address=' + address;
$.ajax({
type: "POST",
url: "boxesadd.php",
data: data,
success: function (data) {
$("#boxform").get(0).reset();
$('#addbox').html(data);
//$("#form").dialog('close');
$("#flex1").flexReload();

}
});
return false;

});

$("#boxform").dialog('open');

}

html

<script language="javascript" type="text/javascript">
$(function() {
$("#company").live('change', function() { if ($(this).val()!="")
$.get("../../getOptions.php?customer=" + $(this).val(), function(data) {
$("#divId").html(data); }); });
});
</script

<form id="boxform" method="post" class="webform" name="boxform" />

<label for="company">Select a Company:</label>
<select name="company" id="company" />
<option SELECTED VALUE="">Select a Company</option>
<?php
do {
?>
<option value="<?php echo $row_Recordsetcust['customer']?>"><?php echo $row_Recordsetcust['customer']?></option>
<?php

}
while ($row_Recordsetcust = mysql_fetch_assoc($Recordsetcust));
$rows = mysql_num_rows($Recordsetcust);
if($rows > 0)

{
mysql_data_seek($Recordsetcust, 0);
$row_Recordsetcust = mysql_fetch_assoc($Recordsetcust);
}

?>
</select>

<!--- displays the address from the change function -->
<div id="divId"></div>

最佳答案

尝试改变

<form id="boxform" method="post" class="webform" name="boxform" />

<form id="boxform" method="post" class="webform" name="boxform"> 

<select name="company" id="company" />

<select name="company" id="company">

var company = $('.company').val();

var company = $('#company').val();

关于javascript - jquery post 在 firebug 中未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6738409/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com