Advertisement
AkashSaikia

Ajax reqeuest from browser console. Automatic loading of jQ

May 2nd, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     // Load the script
  3.     var script = document.createElement("SCRIPT");
  4.     script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
  5.     script.type = 'text/javascript';
  6.     document.getElementsByTagName("head")[0].appendChild(script);
  7.  
  8.     // Poll for jQuery to come into existance
  9.     var checkReady = function(callback) {
  10.         if (window.jQuery) {
  11.             callback(jQuery);
  12.         }
  13.         else {
  14.             window.setTimeout(function() { checkReady(callback); }, 100);
  15.         }
  16.     };
  17.  
  18.     // Start polling...
  19.     checkReady(function($) {
  20. $.ajax({
  21. type: "POST",
  22. url: "http://192.168.0.199/request.php",
  23. data:"key1=value1&key2=value2"
  24. });    });
  25. })();
  26.  
  27. // this code sends ajax request to the spcific URL with post data as mentioned.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement