SHARE
TWEET

Untitled

a guest Oct 23rd, 2014 344 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function () {
  2.     function getCookie(cname) {
  3.         var name = cname + "=";
  4.         var ca = document.cookie.split(';');
  5.         for(var i=0; i<ca.length; i++) {
  6.             var c = ca[i];
  7.             while (c.charAt(0)==' ') c = c.substring(1);
  8.             IF (c.indexOf(name) != -1) return c.substring(name.length,c.length);
  9.         }
  10.         return "";
  11.     }
  12.     $pn_request_error = $('#pn-error');
  13.     $pn_request_success = $('#pn-success');
  14.     $token_success = $("#token-success");
  15.     $token_error = $("#token-error");
  16.     $("#checkout_form").submit(function(e) {
  17.         $form = $(this);
  18.         e.preventDefault();
  19.  
  20.         $.ajax({
  21.             type: "POST",
  22.             url: $form.attr("action"),
  23.             data: $form.serialize(),
  24.             dataType:"json",
  25.             success: function(data){
  26.                 var type=$form.data('type');
  27.                 IF(type=="checkout"){
  28.                     $pn_request_success.slideDown(400).delay(800).slideUp('slow');
  29.                     $form.hide();
  30.                     $("#pn-modal-text").hide();
  31.                     $("#token-modal-text").show();
  32.                     $("#token_form").show();
  33.                 }
  34.             },
  35.             error: function(xhr){
  36.                 var resp = JSON.parse(xhr.responseText);
  37. //                $pn_request_error.text(resp["error"]);
  38.                 $pn_request_error.slideDown(400).delay(800).slideUp('slow');
  39.             }
  40.  
  41.         });
  42.  
  43.     });
  44.  
  45.     $("#token_form").submit(function (e) {
  46.         $form = $(this);
  47.         e.preventDefault();
  48.         var data = $form.serialize();
  49.         data['csrf_token'] = getCookie('csrftoken');
  50.         $.ajax({
  51.             type: "POST",
  52.             url: $form.attr("action"),
  53.             data: data,
  54.             dataType:"json"
  55.         }).success(function(data){
  56.             $('#id_token').val();
  57.             $token_success.slideDown(400).delay(800).slideUp('slow');
  58.             $('#token_form').hide();
  59.             $("#token-modal-text").hide();
  60.             $("#agent-modal-text").show();
  61.             $("#purchase_package").show();
  62.         }).fail(function(msg){
  63.             $token_error.slideDown(400).delay(800).slideUp('slow');
  64.         });
  65.     });
  66.  
  67. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top