0

How can I get the dynamic content that was injected to a web page using ajax?

How can I check in code (no matter which language, just the principals) if an ajax call was actually made on a web page?

Thanks

user3364652
  • 443
  • 7
  • 20
  • 1
    *I know that behind this address there is something like "www.somegameaddress.com/name=Dallas"* How do you know that? How do you know the results you are seeing weren't fetched with an AJAX call and injected into the site's current page? – Scott Marcus Sep 21 '17 at 20:34
  • 1
    Look in the network console. Likely some AJAX call – mplungjan Sep 21 '17 at 20:34
  • @mplungjan he wants the URL address. Network console won't help him. – walv Sep 21 '17 at 20:35
  • @user3364652 if browser doesn't give you this ability then you won't be able to get it. – walv Sep 21 '17 at 20:35
  • @walv But the Network tab will let him know if an AJAX call is being made and that is what mplungjan is referring to. – Scott Marcus Sep 21 '17 at 20:35
  • Let's say the results is a different page from the search page. It can still be ajax call? – user3364652 Sep 21 '17 at 20:36
  • Yes, it can be and most likely is. It makes no sense to create a separate page for each possible result. – Scott Marcus Sep 21 '17 at 20:36
  • @Scott Marcus he will see the call to the backend, but what he needs is dynamic URL which he can paste in the browser and his Dallas NBA results will appear. – walv Sep 21 '17 at 20:37
  • @walv I understand that. What we're trying to tell you is that he can determine if AJAX is involved by looking at the Network tab. If AJAX calls are being made, then getting the URL will not be possible. – Scott Marcus Sep 21 '17 at 20:38
  • What I actually need is the content of the Dallas results page. How can I get it without doing some GUI automation for getting to that page? – user3364652 Sep 21 '17 at 20:39
  • 1
    Do you mind sharing the site link? It probably uses POST requests which have the `name:"Dallas"` parameter, but is not shown in the URL (https://stackoverflow.com/questions/14551194/how-are-parameters-sent-in-an-http-post-request) – yuriy636 Sep 21 '17 at 20:39
  • Again, it is most likely that it isn't a "page" you need to get to. Most likely it is the results of an AJAX call that are being injected into the result page. – Scott Marcus Sep 21 '17 at 20:40
  • @user3364652 please update the description of your question because it says one thing but in the comments you want another. – walv Sep 21 '17 at 20:41
  • I dont have some specific link, I'm just trying to understand the basic idea for a program I want to build. – user3364652 Sep 21 '17 at 20:41
  • @walv I know what he wants. Perhaps he cannot get what he wants or perhaps the use an iFrame or are ajaxing html in which case ha CAN get what he wants – mplungjan Sep 22 '17 at 04:06

2 Answers2

1

To do this, the anchors are usually used.

Sample URL

www.somegameaddress.com/#/name=Dallas

example function using jquery:

$(function () {
  $(window).bind('hashchange', function (e) {
    var anchor = document.location.hash;
    console.log(anchor);
    $.ajax({
      url : anchor,
      success : function(data){
        $('body').html(data); // print data received in to body
      }
    });
  });
});

I hope to be of help to you!

Pinguto
  • 361
  • 1
  • 11
0

The answer is hidden in your question.

Dynamic means Ajax. To check the url which is called, you can browse either the Network Tab from the console (so you see all requests), this is faster.

Optionally, you can browse the scripts hoping to find where that ajax call is made, if it's called from client side.

This is a very basic post ajax call from jquery.

$("button").click(function(){
    $.post("url.php", function(data, status){
        alert("Data: " + data + "\nStatus: " + status);
    });
});
jack
  • 1,353
  • 6
  • 20