I’ve this check web page on a web site – https://piclits.com/test-slideshow/
It shows a bunch of photographs/PICLITS and grabs them randomly from a folder 12 at a time right into a slideshow.
I wish to electronic mail the primary picture with out refreshing the web page (which might deliver up 12 new photographs) from the e-mail button which opens up a popup so as to add electronic mail addresses.
All is nice – I can seize the picture and mail it however the script does one thing wacky the place it flashes on the web page after which hangs up at admin-ajax.php slightly than simply staying on the web page and sending the e-mail.
My Kind:
<type id="ajaxformid" motion="<?php echo admin_url( 'admin-ajax.php' ); ?>" technique="POST">
<p>E mail this PIC-LIT to a pal.</p>
<p>You might embrace a number of emails in case you separate them with a comma.</p>
<ul type="list-style-type: none;">
<li>E mail: <textarea title="piclit_email" id="piclit_email" rows="4" cols="50" autocomplete="on" autofocus=""></textarea><enter sort="hidden" title="founder_piclit" id="founder_piclit" worth=""></li>
<li><enter sort="hidden" title="piclit_bcc" class="piclit_bcc" worth="0"></li>
<li>bcc: <enter sort="checkbox" title="piclit_bcc" class="piclit_bcc" worth="1"><br></li>
<enter sort="hidden" title="action" worth="fiveb_ajax_mail">
<?php wp_nonce_field( 'fiveb_ajax_nonce', 'fiveb_nonce_field' ); ?>
<li><enter sort="submit" title="submit" worth="Send"></li>
</ul>
</type>
Javascript:
<script>
jQuery(doc).prepared(perform(){
var frm = $('#ajaxformid');
frm.submit(perform (e) {
jQuery('#piclits-popup').magnificPopup.shut();
e.preventDefault();
var piclit_email = jQuery( "#piclit_email" ).val();
var founder_piclit = jQuery( "#founder_piclit" ).val();
var piclit_bcc = jQuery('.piclit_bcc').val(),
var formData = {
piclit_email: piclit_email,
founder_piclit: founder_piclit,
piclit_bcc: piclit_bcc,
motion: 'fiveb_function'
};
$.ajax({
sort : 'POST',
url : '<?php echo admin_url( 'admin-ajax.php' ); ?>',
dataType : 'json',
information : formData,
}).completed(perform(information) {
console.log(information);
}).fail(perform(information) {
console.log(information);
});
});
});
</script>
and php:
perform fiveb_function() {
if ( ! isset( $_REQUEST['fiveb_nonce_field'] ) || ! wp_verify_nonce( $_REQUEST['fiveb_nonce_field'], 'fiveb_ajax_nonce') ) {
exit("No naughty business please");
}
$topic = 'View A Founder PIC-LIT from piclits.com';
$piclit_email = strval($_REQUEST['piclit_email']);
$founder_piclit = strval($_REQUEST['founder_piclit']);
$piclit_bcc = strval($_REQUEST['piclit_bcc']);
if ($piclit_bcc) {
$headers[] = 'Bcc: '.$piclit_email;
}
if ($piclit_email == '') $fieldError = true;
if (!isset($fieldError)) {
$message = '<html><head><title>Founder PIC-LIT</title></head><physique><desk border="0" cellspacing="2" cellpadding="20" bgcolor="#ffffff" width="100%"><tbody><tr><td></td><td width="600"><p type="text-align: center">Hi there!<br />View A Founder PIC-LIT from <a href="https://piclits.com">piclits.com</a>.</p></td><td></td></tr><tr><td></td><td><img src="'.$founder_piclit.'" alt="Founder PIC-LIT" width="600" type="display:block;width:100%" /></td><td></td></tr></tbody></desk></physique></html>';
$headers[] = 'From: PIC-LITS <hiya@piclits.com>';
$headers[] = 'Content material-Kind: textual content/html; charset=UTF-8';
if ($bcc) $sent_mail = wp_mail( "", "$subject", $message, $headers );
else $sent_mail = wp_mail( "$piclit_email", "$subject", $message, $headers );
if ($sent_mail) {
echo 'electronic mail despatched';
die();
} else {
echo 'There was an error. Sorry your electronic mail was not despatched.';
die();
}
} else {
echo '<script sort ="text/JavaScript">';
echo 'alert("Please fill in all fields to send an email.")';
echo '</script>';
die();
}
}
Looks as if I’m so shut however I can not get the script to cease hanging up on admin-ajax.php. Any assist can be so appreciated! Possibly it has one thing to do with my popup? I’m out of concepts!