So I’m utilizing jQuery and pHp collectively to ship an e-mail to myself each time a person clicks on the replace button of their Final Member type. Nonetheless, the e-mail solely sends when a person is utilizing Chrome, IE, and Microsoft Edge. When utilizing Safari and Firefox, it would not work. I’m utilizing a click on occasion listener to ship JSON to my pHp file. The JSON was initially an object that was created by a operate that checks for the variations between two totally different objects. These objects have been created utilizing DOM traversal. In that pHp file is a mail() operate that sends me the aforementioned JSON to my e-mail. I’ve tried replicating the method on a check website and seen that once I didnt add the jQuery that comes earlier than my click on listener, emails do certainly get despatched from Safari and Firefox. Nonetheless, if I add the jQuery code and THEN take away it and check once more it will not ship! It is as if my server will get completely rejected. Right here is my JS code:
(operate($){
$(doc).prepared(operate(){
console.log('mailajax is enqueued, displaying on firefox');
var ogArray = new Array(),
newArray = new Array(),
dropOgArray = new Array(),
dropNewArray = new Array(),
distinction,
username = $('.um-name').discover('a').attr('title');
operate diffObject(a, b) {
return Object.keys(a).cut back(operate(map, ok) {
if (a[k] !== b[k]) map[k] = b[k];
return map;
}, {});
}
$('enter.um-form-field').every(operate() {
var $key = $(this).closest('.um-field').discover('label').textual content();
var $worth = $(this).val();
ogArray[$key] = $worth;
});
console.log(ogArray);
setTimeout(operate(){
$('span.select2-chosen').every(operate() {
var $key = $(this).closest('.um-field').discover('label').textual content();
var $worth = $(this).textual content();
// console.log($worth);
dropOgArray[$key] = $worth;
});
console.log(dropOgArray);
},1000);
$('enter.um-form-field').on('keyup', operate(){
$('type').discover('enter.um-form-field').every(operate() {
var $key = $(this).closest('.um-field').discover('label').textual content();
var $worth = $(this).val();
newArray[$key] = $worth;
});
console.log(newArray);
console.log(diffObject(ogArray, newArray));
distinction = diffObject(ogArray, newArray);
});
$('choose.um-form-field').on('change', operate(){
setTimeout(operate(){
$('type').discover('span.select2-chosen').every(operate() {
var $key = $(this).closest('.um-field').discover('label').textual content();
var $worth = $(this).textual content();
dropNewArray[$key] = $worth;
});
console.log(diffObject(dropOgArray, dropNewArray));
dropDifference = diffObject(dropOgArray, dropNewArray);
}, 1000);
});
$('.um-profile-body .um-button').on('click on', operate(e) {
$('type').on('submit', operate(){
console.log('type was despatched efficiently');
var ajaxurl = 'http://www.reformeducators.org/wp-content/themes/NATE/admin-ajax.php';
stringDifference = JSON.stringify(distinction);
stringDropDifference = JSON.stringify(dropDifference);
stringUsername = String(username);
$.put up(ajaxurl, {'Title': stringUsername, 'Adjustments Made': stringDifference, 'Drop Down Menu Adjustments': stringDropDifference});
});
});
});
})(jQuery);
And right here is my pHp code:
<?php
$message = "Person Data has been changedrn";
$message .= print_r($_POST, true);
$to = "testing@area.com";
$topic = "Person info has been modified!";
$headers = "From: ";
mail($to, $topic, $message, $headers);
?>
I believe this is likely to be a server concern, but when anybody has any expertise doing one thing like this, I’d actually admire some suggestions or assist.