Reputation: 3
I have tried return false; and i have tried event.preventdefault and neither one seems to work in Firfox. It works just fine in Chrome, but not in IE or Firefox? grabs the info from the current page, sends it via ajax to an update script and then updated a database. if firefox is used all it does it reloads the page and doesnt do any updating.
here's the code for the button:
<div class="col-md-12 text-right">
<button class="btn btn-primary btn-sm" id="savebutton" onclick="editthisframily();"><span class="fa fa-lg fa-floppy-o"></span><span id="framilyeditbutton"> Update Framily </span></button>
<button class="btn btn-danger btn-sm" id="deletebutton"><span class="fa fa-lg fa-remove"></span><span id="framilydeletebutton"> Delete Framily</span></button>
</div>
// update framily member
// ========================
function editthisframily() {
return false;
//event.preventDefault();
var testdate = $('#ebirthday').val();
if(testdate.length > 5 ) {
if(moment(testdate, ["MM/DD/YYYY"]).isValid()) {
//alert("good");
}
else {
alert("date is bad");
return;
}}
$('#framilyeditbutton').text(' Updating Framily. Please Wait ...');
if($('#egender-f').is( ":checked" )) {
var gender = "f";
}
else {
var gender = "m";
}
if($('#remindertype_email').is( ":checked" )) {
var remindertype_email = "true";
}
else {
var remindertype_email = "false";
}
if($('#remindertype_sms').is( ":checked" )) {
var remindertype_sms = "true";
}
else {
var remindertype_sms = "false";
}
var myData = 'address1='+ $("#eaddress1").val()+'&address2='+$("#eaddress2").val()+'&city='+$("#ecity").val()+'&state='+$("#estate").val()+'&zipcode='+$("#ezipcode").val()+'&country='+$("#ecountry").val()+'&telephone='+$("#etelephone").val()+'&birthday='+$("#ebirthday").val()+'&gender='+gender+'&fullname='+$("#efullname").val()+'&email='+$("#eemail").val()+'&userid='+$("#userid").val()+'&relationship='+$("#erelationship").val(); //build a post data structure
// console.log(myData);
jQuery.ajax({
type: "POST", // HTTP method POST or GET
url: "includes/updateframily.php", //Where to make Ajax calls
dataType:"text", // Data type, HTML, json etc.
data:myData, //Form variables
success:function(response){
$("#responds").append(response);
setTimeout(function() {
$('#framilyeditbutton').text(' Framily Member Updated ');
framilyView();
$('#framilyeditbutton').text(' Update Framily Member ');
}, 3000)
},
error:function (xhr, ajaxOptions, thrownError){
// $("#FormSubmit").show(); //show submit button
// $("#LoadingImage").hide(); //hide loading image
$('#buttontext').text(' something went wrong');
alert(thrownError);
}
});
};
Upvotes: 0
Views: 88
Reputation: 887365
You need to return the value of the function in your inline handlers:
onclick="return editthisframily()"
Upvotes: 1