Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- STEP 1
- --------------------------------------------------------------------
- >> In both files subscribe.php and unsubscribe.php in your Sendy root directory
- on top, just below <?php, add:
- header('Access-Control-Allow-Origin: *');
- Same files, find:
- ?>
- <!DOCTYPE html>
- >> Change this to:
- // custom mod for ajax subscription form
- if(isset($_POST['do_ajax'])){
- echo json_encode(strip_tags($feedback));
- exit();
- }
- ?>
- <!DOCTYPE html>
- STEP 2
- --------------------------------------------------------------------
- >> Save the code below in a new file, name it "subscribe_ajax.php" and save it in your Sendy root directory
- <?php
- // configuration | change these values to reflect your list
- $list = "UZiGZ22lF1njeyaAt763csaw";
- $sendy_url = "http://scripturlhere.com";
- $purpose = "subscribe" // (subscribe OR unsubscribe) // is this a subscribe or unsubscribe form?
- ?>
- <script src="http://code.jquery.com/jquery-latest.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- $("#message").html('');
- $("#subscription_form").submit(function(){
- $("#message").html('');
- var name = $('input[name=name]').val();
- var list = $('input[name=list]').val();
- var email = $('input[name=email]').val();
- var querystring = "name="+name+"&email="+email+"&list="+list+"&do_ajax=yes";
- $.ajax({
- url: 'http://newsletter.zwembad.eu/<?php echo $purpose; ?>.php',
- type: "POST",
- data: querystring,
- success: function(data) {
- $("#message").html(data);
- }
- });
- return false;
- });
- });
- </script>
- <div id="message"></div>
- <form id="subscription_form" action="<?php echo $sendy_url; ?>/<?php echo $purpose; ?>.php" method="POST" accept-charset="utf-8">
- <?php if($purpose=="subscribe"){ ?>
- <label for="name">Name</label><br/>
- <input type="text" name="name" id="name"/>
- <br/>
- <?php } ?>
- <label for="email">Email</label><br/>
- <input type="text" name="email" id="email"/>
- <br/>
- <input type="hidden" name="list" value="<?php echo $list; ?>"/>
- <input type="submit" name="submit" id="submit"/>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement