Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 20th, 2012  |  syntax: JavaScript  |  size: 1.15 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function getCookie(name) {
  2.     var cookieValue = null;
  3.     if (document.cookie && document.cookie != '') {
  4.         var cookies = document.cookie.split(';');
  5.         for (var i = 0; i < cookies.length; i++) {
  6.             var cookie = jQuery.trim(cookies[i]);
  7.             // Does this cookie string begin with the name we want?
  8.             if (cookie.substring(0, name.length + 1) == (name + '=')) {
  9.                 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
  10.                 break;
  11.             }
  12.         }
  13.     }
  14.     return cookieValue;
  15. }
  16. function verify(infoid, status)
  17. {
  18.     alert('iiii')
  19.         var xmlhttp;
  20.         if (window.XMLHttpRequest)
  21.         {// code for IE7+, Firefox, Chrome, Opera, Safari
  22.            xmlhttp=new XMLHttpRequest();
  23.         }
  24.         else
  25.         {// code for IE6, IE5
  26.            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  27.         }
  28.         xmlhttp.onreadystatechange = function()
  29.         {
  30.            if (xmlhttp.readyState==4 && xmlhttp.status==200)
  31.            {
  32.                alert('ok')
  33.            }
  34.         }
  35.         xmlhttp.open("POST", "/verify/" + infoid, true);
  36.         xmlhttp.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
  37.         if (status == 1)
  38.            xmlhttp.send("Submit=1&redirect=0");
  39. }