我在下面有以下AJAX请求,可以在chrome中使用但不是safari吗?我认为Chrome使用的是Safari HTML。我的Javascript控制台在safari和chrome上都没有错误。第一个submit()函数检查重复的条目,如果没有重复的条目,则第二个ajax提交数据。一切都适用于Chrome,但不适用于Safari。有什么建议吗?
function submit() {
var bin = document.getElementById("bin_number").value;
var barcode = document.getElementById("barcode").value;
document.getElementById("alert").className = '';
document.getElementById("alert").innerHTML = '';
$.ajax({
url: '?a=ajax_check_scan_to_bin&bin='+bin+'&barcode='+barcode+'',
type: 'GET',
contentType: "text/xml",
dataType: "text",
success: function(data){
if(data > 0) {
document.getElementById("form-group-"+id).className = 'form-group has-error has-feedback';
document.getElementById("alert").className = 'alert alert-danger';
document.getElementById("alert").innerHTML = 'This Barcode and Bin have Been Scanned Already';
} else {
document.getElementById("submit-btn").className = 'btn btn-block btn-lg btn-success';
submit_form();
}
},
error: function(){
alert('some error happened');
}
});
}
function submit_form(){
var bin = document.getElementById("bin_number").value;
var barcode = document.getElementById("barcode").value;
$.ajax({
url: '?a=post_scantobin&bin_number='+bin+'&barcode='+barcode+'',
type: 'GET',
contentType: "text",
dataType: "text",
success: function(data){
if(data == '0') {
document.getElementById("alert").className = 'alert alert-warning';
document.getElementById("alert").innerHTML = 'Transaction Entered - Unable to Load into External Database';
} else if (data == '1') {
document.getElementById("alert").className = 'alert alert-success';
document.getElementById("alert").innerHTML = 'Transaction Entered Successfully';
} else {
document.getElementById("alert").className = 'alert alert-danger';
document.getElementById("alert").innerHTML = data;
}
},
error: function(){
alert('some error happened');
}
});
}
</script>
<div class="panel panel-default">
<div class="panel-body">
<div class="row clearfix">
<div class="col-md-4 col-md-offset-4 column">
<div class="" id='alert' role="alert"></div>
<div class="form-group" id="form-group-bin">
<label for="bin_number" class='control-label'>Scanning to Bin</label><input onchange="check('bin');" type="number" class="form-control input-lg" name="bin_number" id="bin_number" />
</div>
<div class="form-group" id='form-group-barcode'>
<label for="barcode" class='control-label'>Item Barcode:</label><input onchange="check('barcode');" type="text" class="form-control input-lg" name="barcode" id="barcode" />
</div>
<button id="submit-btn" type="button" onblur="submit();" class="btn btn-block btn-lg btn-default">Submit</button>
</div>
</div>
</div>
</div>