2

i have this problem that i can't solve for days now...here is my code. i want to get the xmlhttprequest or the url that loads everytime i clicked the $("#btnQuery"). what happened here is when i clicked the button, it will display the data in jqgrid from the server.

   $("#btnQuery").click( function() {
      var params = {
         "ID": $("#eID3").val(),
         "dataType": "data"
      }
      var url = 'process.php?path=' + encodeURI('project/view') + '&json=' + encodeURI(JSON.stringify(params));
      $('#tblD').setGridParam({
          url:url, 
          datatype: ajaxDataType,  
      });

      $('#tblD').trigger('reloadGrid');   

      $('#firstur').append('the url: ' + url+'<br>');//the xmlhttpRequest should disply here in my html
      $('#secur').append('response: ' + url+'<br>'); //the response of xmlhttpRequest should display here in my html
   });

here's the code of my process.php. this is where i'm going to get the data for my jqgrid.

   <?php
       print(file_get_contents("http://localhost/" . $_GET["path"] . "?json=" . ($_GET["json"])));
   ?>

in firebug console, the xmlhttprequest/location that displays is: http://localhost/process.php?....%22:%22%22,%22Password%22:%22%22%7D

and it's response body is simething like:

{"result":{"ID":"1C1OMk123tJqzbd"}, "time_elapsed":0}

does anybody here knows how to get the url/xmlhttprequest that loads to get the data? and its response body? i wan to display it in my html body aside from my jqgrid...is there anyone who can help me?..please... thank you so much

jayAnn
  • 827
  • 3
  • 18
  • 38

3 Answers3

1

Well, I'm not suggesting this as good form, but you ought to be able to redefine the send function on the XHR, to intercept any requests going out, grab the original response handler, wrap it in your own handler so you can still call the original function, but insert your own data in there. For a rough example:

Firefox, fix for other browsers:

XMLHttpRequest.prototype.originalSend = XMLHttpRequest.prototype.send;

var myFunction = function(response) {
    //do stuff 
    this.originalReadyStateHandler(response);
}

XMLHttpRequest.prototype.send = function(optional val) {
    this.originalReadyStateHandler = this.onreadystatechange;
    this.onreadystatechange = myFunction;
    this.originalSend(val);
}

Or something to that effect, again, I'm not saying I recommend this, but it could accomplish what it sounds like you're after.

Myles
  • 20,860
  • 4
  • 28
  • 37
  • ohh, thank you myles for answering. i honestly don't understand the code you gave but i will study that and hopefully...it will help me solve my prob. thank you so much... – jayAnn Mar 17 '11 at 02:09
1

finally, i already figured out how to do solve my own problem.... here's the code:

    var myUrl = $("#tblData").getGridParam('url');
    myUrl += '&json=' + JSON.stringify(jpar); 

   //add something here to show the myUrl;

.getGridParam returns the url from options array. you can return some parameters using it. just visit this site: http://www.secondpersonplural.ca/jqgriddocs/_2eb0fi5wo.htm for more info regarding jqgrid methods (methods, parameters, desrciption).

jayAnn
  • 827
  • 3
  • 18
  • 38
0

Open the "Network" tab in Firefox' Firebug extension and you'll see what URLs are loaded. Alternatively use Wireshark to see what flows through your cables.

cweiske
  • 30,033
  • 14
  • 133
  • 194
  • thank you so much for the answer, but i already know how to do that., and what i need is a javascript code (if there's someone who knows how to do it) that can output the same as the firebug. is there anybody who knows how to do it? please... – jayAnn Mar 17 '11 at 01:34