Reputation: 608
I have a form that is working on Firefox but doesn't work on Chrome. The form submits via 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();
});
});
});
I looked into similar topics, tried changing the type of the submit button to "button" instead of "submit", checked the document declaration and still haven't found a solution.
The console doesn't display any errors on chrome.
What could be the reason?
Upvotes: 1
Views: 315
Reputation: 1945
Your $.ajax call is handled by $('.btnStergere').click, but then is no really a button with such class You propabaly want to move
$.ajax({
type: "POST",
url: "/cmajax.php",
data: { cmd: "remQuote", pid: pidd }
})
.done(function( msg ) {
location.reload();
});
});
under
$('#gform_submit_button_1').click(function(event) {
try this one :
$('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>
Upvotes: 1