Ajax表单不提交在Chrome上
Ajax form not submitting on Chrome
我有一个在Firefox上工作的表单,但在Chrome上不起作用。表单通过AJAX提交。
<div class="container-fluid">
<div class="row container">
<?php if (count($products) != 0) { ?>
<form action="/cmajax.php" method="GET" class="gform">
<label class='gfield_label' for='input_1_4'>
Alege Magazinul
<span class='gfield_required'>*</span>
</label>
<select name='cMagazin' id='input_1_4' onchange='gf_apply_rules(1,[0]);' class='medium gfield_select' tabindex='1'>
<option value='Bucuresti - Baneasa' selected='selected'>Bucuresti - Baneasa</option>
<option value='Craiova'>Craiova</option>
<option value='Constanta'>Constanta</option>
<option value='Cluj'>Cluj</option>
<option value='Timisoara'>Timisoara</option>
<option value='Iasi'>Iasi</option>
<option value='Pitesti'>Pitesti</option>
<option value='Sibiu'>Sibiu</option>
<option value='Targu Mures'>Targu Mures</option>
</select>
<label class='gfield_label' for='input_1_1'>Nume</label>
<input name='cName' id='input_1_1' type='text' value='' class='medium' tabindex='2' />
<label class='gfield_label' for='input_1_5'>Telefon</label>
<input name='cTelefon' id='input_1_5' type='text' value='' class='medium' tabindex='3' />
<label class='gfield_label' for='input_1_3'>Email</label>
<input name='cEmail' id='input_1_3' type='text' value='' class='small' tabindex='4' />
<label class='gfield_label' for='input_1_6'>Mesaj</label>
<textarea name='cText' id='input_1_6' class='textarea medium' tabindex='5' rows='10' cols='50'></textarea>
<input name='cID' id='input_1_11' type='hidden' class='gform_hidden' value='<?php echo $productsList; ?>' />
<input name='cmd' id='input_1_10' type='hidden' class='gform_hidden' value='sendCerere' /><br/><br/>
<input type='button' id='gform_submit_button_1' class='rovereButton button gform_button' value='Cere Cotatie' tabindex='6' />
</form>
<?php } ?>
</div>
</div>
$('document').ready(function() {
console.log('x');
$('#gform_submit_button_1').click(function(event) {
if ($('#input_1_5').val() == '') {
event.preventDefault();
alert('Va rugam completati numarul dvs de telefon!');
return false;
}
if ($('#input_1_3').val() == '') {
event.preventDefault();
alert('Va rugam completati adresa dvs de email!');
return false;
}
$('#gform_submit_button_1').prop("disabled", true);
});
$('.btnStergere').click(function(ev) {
ev.preventDefault();
var pidd = $(this).attr('data-cm-prodid');
var btn = $(this);
$.ajax({
type: "POST",
url: "/cmajax.php",
data: {
cmd: "remQuote",
pid: pidd
}
}).done(function(msg) {
location.reload();
});
});
});
我查看了类似的主题,尝试将提交按钮的类型更改为"button"而不是"submit",检查了文档声明,但仍然没有找到解决方案。
控制台显示chrome上没有任何错误。
原因是什么?
您的$。ajax调用由$('. btnstergere ')处理。点击,但随后就没有真正具有这样类的按钮了你可能想要移动
$.ajax({
type: "POST",
url: "/cmajax.php",
data: { cmd: "remQuote", pid: pidd }
})
.done(function( msg ) {
location.reload();
});
});
下 $('#gform_submit_button_1').click(function(event) {
jsfiddle联系
试试这个:
$('document').ready(function(){
$('#gform_submit_button_1').click(function(event) {
if ($('#input_1_5').val() == '') {
event.preventDefault();
alert('Va rugam completati numarul dvs de telefon!');
return false;
}
if ($('#input_1_3').val() == '') {
event.preventDefault();
alert('Va rugam completati adresa dvs de email!');
return false;
}
$('#gform_submit_button_1').prop( "disabled", true );
var pidd = $(this).attr('data-cm-prodid');
var btn = $(this);
$.ajax({
type: "POST",
url: "/cmajax.php",
data: { cmd: "remQuote", pid: pidd }
})
.done(function( msg ) {
location.reload();
});
});
});
<div class="container-fluid">
<div class="row container">
<form action="/cmajax.php" method="GET" class="gform">
<label class='gfield_label' for='input_1_4'>Alege Magazinul<span class='gfield_required'>*</span></label>
<select name='cMagazin' id='input_1_4' onchange='gf_apply_rules(1,[0]);' class='medium gfield_select' tabindex='1' >
<option value='Bucuresti - Baneasa' selected='selected'>Bucuresti - Baneasa</option>
<option value='Craiova' >Craiova</option>
<option value='Constanta' >Constanta</option>
<option value='Cluj' >Cluj</option>
<option value='Timisoara' >Timisoara</option>
<option value='Iasi' >Iasi</option>
<option value='Pitesti' >Pitesti</option>
<option value='Sibiu' >Sibiu</option>
<option value='Targu Mures' >Targu Mures</option>
</select>
<label class='gfield_label' for='input_1_1'>Nume</label>
<input name='cName' id='input_1_1' type='text' value='' class='medium' tabindex='2' />
<label class='gfield_label' for='input_1_5'>Telefon</label>
<input name='cTelefon' id='input_1_5' type='text' value='' class='medium' tabindex='3' />
<label class='gfield_label' for='input_1_3'>Email</label>
<input name='cEmail' id='input_1_3' type='text' value='' class='small' tabindex='4' />
<label class='gfield_label' for='input_1_6'>Mesaj</label>
<textarea name='cText' id='input_1_6' class='textarea medium' tabindex='5' rows='10' cols='50'></textarea>
<input name='cID' id='input_1_11' type='hidden' class='gform_hidden' value='' />
<input name='cmd' id='input_1_10' type='hidden' class='gform_hidden' value='sendCerere' />
<br/><br/>
<input type='button' id='gform_submit_button_1' class='rovereButton button gform_button' value='Cere Cotatie' tabindex='6' />
</div></div>
相关文章:
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- JS更改无法在Chrome中提交
- 提交按钮不会;不适用于Chrome或Firefox,但适用于Internet Explorer
- 点击时禁用提交按钮,将阻止表单在谷歌Chrome上提交
- 为什么在 Chrome 中按回车键时我的表单没有提交
- 为什么在IE和Chrome中提交表单不起作用
- 提交Chrome扩展程序表单
- onsubmit不调用Chrome中的js函数,而是直接提交表单
- HTTP POST 在 Chrome 中自动提交
- 表单提交在Chrome中不起作用,即
- 表单上提交返回 false 在 Chrome 中不起作用
- 此代码阻止我的表单提交(仅在 chrome 中,适用于 IE 和 Firefox)
- 文件输入 :Chrome 在提交表单之前不会检查文件是否仍然存在
- Chrome - 如何通过javascript提交具有输入名称=submit的表单
- 提交按钮不会出现在Firefox中,而是出现在Chrome和Internet Explorer上
- Chrome 警告框会提交网页,即使返回 false
- Ajax在Chrome / Safari中提交作品,但不能在Firefox / IE中提交作品
- jQuery 表单提交事件处理程序不会被调用(chrome 扩展)
- iPad Chrome -提交表单在新的窗口/标签不工作
- 当Unicode数据从Chrome提交到ASP时,Unicode字符串会发生变化.网络页面