我创建了 jquery 选项卡,并且在选项卡内部有一个表单,在它的底部有这个按钮。
<button id="submitForm" onclick="formSubmition();">Submit</button>
这是标题
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="js/lib.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" href="css/style.css" />
formSubmition() 存在于 lib.js 文件中,这是它的代码
function formSubmition(){
$recId = $("#recId").val();
$collectionDate = $("#collectionDate").val();
$collectorsName = $("#collectorsName").val();
$donorsName = $("#donorsName").val();
$sciName = $("#sciName").val();
$family = $("#family").val();
$comName = $("#comName").val();
$variety = $("#variety").val();
$area = $("#area").val();
$location = $("#location").val();
$altitude = $("#altitude").val();
$geoOrientation = $("#geoOrientation").val();
$geoCoordinates = $("#geoCoordinates").val();
$soilDescription = $("#soilDescription").val();
$habitatDescription = $("#habitatDescription").val();
$plantPopulation = $("#plantPopulation").val();
$photoDate = $("#photoDate").val();
$photoId = $("#photoId").val();
$photoComments = $("#photoComments").val();
$soilTaken = 0;
$seedQuantity = $("#seedQuantity").val();
$plantQuantity = $("#plantQuantity").val();
$graftQuantity = $("#graftQuantity").val();
$moreInfo = $("#moreInfo").val();
if($('#soilTaken').is(':checked')) // Checking if Checkbox was checked.
$soilTaken = 1;
jQuery.ajax({
type: 'POST',
async: true,
url: 'classes/classController.php',
data: {method: "recNewPlant", recId: $recId, collectionDate: $collectionDate, collectorsName: $collectorsName, donorsName: $donorsName, sciName: $sciName, family: $family, comName: $comName, variety: $variety, area: $area, location: $location, altitude: $altitude, geoOrientation: $geoOrientation, geoCoordinates: $geoCoordinates, soilDescription: $soilDescription, habitatDescription: $habitatDescription, plantPopulation: $plantPopulation, photoDate: $photoDate, photoId: $photoId, photoComments: $photoComments, soilTaken: $soilTaken, seedQuantity: $seedQuantity, plantQuantity: $plantQuantity, graftQuantity: $graftQuantity, moreInfo: $moreInfo},
contentType: ('application/x-www-form-urlencoded'),
dataType: "json",
success : function(json){
if(json.status == '1'){
alert("Added!");
}else{
alert("Problema!");
}
}
});
}
问题是我已经多次使用这种方法,但这是第一次出现这样的行为。我的意思是说。如果我按下按钮,大多数时候什么都不会发生,有时(很少)仅在铬(不在 Firefox 中)它向服务器发送请求并返回“问题”消息。
我已经删除了两个浏览器的缓存,但没有任何改变。此外,我正在使用 OWASP ZAP 查看流量,并且确实没有发送任何 POST 请求。我认为标签可能会导致该问题,但我找不到原因。
这是我设置标签的方式:
$("#mainTabs").tabs();