为什么我的Ajax不能在谷歌Chrome或IE上运行,但可以在FireFox上运行,我怎样才能使它运行起来 这个Ajax代码不适用于chrome和safari。我想用ajax更新我尽力帮助我。
<script> function checkasda<?php echo $pagesRecordprol['id'];?>() {
var quanti = document.getElementById("quanti<?php echo $pagesRecordprol['id'];?>").value;
var prodi = <?php echo $pagesRecordprol['id'];?>;
// alert( quanti +' '+ prodi); var dataString = 'quanti='+ encodeURIComponent(quanti) + '&prodi='+ encodeURIComponent(prodi) ; $.ajax({ async: false, type: "POST", url: "updatecart.php", data: dataString, cache: false, success: function(html){ if(alert('Done')){} else window.location.reload(); window.location.reload(); } }); }
</script>
答案 0 :(得分:0)
您的ID是数字,Chrome和IE失败,因为无法解释为连接...,转换为char / string,
这适用于Chrome:
pagesRecordprol =阵列(&#39; ID&#39; = GT;&#39; 1&#39);
这不适用于Chrome:
pagesRecordprol =阵列(&#39; ID&#39 =大于1);
<pre>
--php--
$pagesRecordprolarray = array('id' => '1');
foreach ($pagesRecordprolarray as $pagesRecordprol) {
echo $pagesRecordprol['id'];
--endphp--
<script> function checkasda<?php echo $pagesRecordprol['id']; ?>() {
var quanti = document.getElementById("quanti<?php echo $pagesRecordprol['id']; ?>").value;
var prodi = <?php echo $pagesRecordprol['id']; ?>;
// alert( quanti +' '+ prodi); var dataString = 'quanti='+ encodeURIComponent(quanti) + '&prodi='+ encodeURIComponent(prodi) ; $.ajax({ async: false, type: "POST", url: "updatecart.php", data: dataString, cache: false, success: function(html){ if(alert('Done')){} else window.location.reload(); window.location.reload(); } }); }
</script>
--php--
}
--endphp--
</pre>
此致