Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="ShowPageContent">
- <a href="openpage.php?page=1" class="loadwithajax" data-page-link="index.php">Open Page One</a>
- <a href="openpage.php?page=2" class="loadwithajax" data-page-link="index.php">Open Page Two</a>
- <a href="openpage.php?page=3" class="loadwithajax" data-page-link="index.php">Open Page Three</a>
- </div>
- <script>
- $(function(){
- "use strict";
- $(document).on('click', '.loadwithajax', function(e){
- var targetUrl = e.target.href;
- var prevUrl = $(this).attr('data-page-link');
- $.ajax({
- type: "POST",
- url: targetUrl,
- data: {targetUrl : targetUrl, prevUrl : prevUrl},
- async: false,
- beforeSend: function(){},
- success: function(htmlBlock){
- $('#ShowPageContent').html(htmlBlock);
- }
- });
- e.preventDefault();
- });
- });
- </script>
- <?php
- $validateForm = 'validate-form-'.md5($_GET['targetUrl']);
- ?>
- <a href="<?php echo $_GET['prevUrl'];?>" class="loadwithajax" data-page-link="">Back To Main Page</a>
- <form action="" method="post" class="<?php echo $validateForm;?>">
- <input type="text" value=""/>
- <input type="submit" value="Send"/>
- </form>
- <script>
- $(function(){
- "use strict";
- $(document).on('submit', '.<?php echo $validateForm;?>', function(e){
- $.ajax({
- type: "POST",
- url: ajax_appserver('shop', 'update_product.php'),
- data: $(self).serialize(),
- beforeSend: function(){},
- success: function(data){
- console.log(data);
- }
- });
- e.preventDefault();
- });
- });
- </script>
Add Comment
Please, Sign In to add comment