dharanbro
dharanbro

Reputation: 1342

finding the ajax request in dojo

I am working on a crawlers to scrap all data from the website. they use ajax for pagination. I found this on the href of the page numbers

javascript:dojo.publish("showResultsForPageNumber",[{pageNumber:"4",pageSize:"15", linkId:"WC_SearchBasedNavigationResults_pagination_link_4_categoryResults"}])

what is happening here. I am not aware of these dojo. Can any one help me to find the corresponding server script so that i can scrap all the data including pagination.

update#1

in the console i found enter image description here

this is the code where it is redirected.

showResultsPage:function(data){

            var pageNumber = data['pageNumber'];
            var pageSize = data['pageSize'];
            pageNumber = dojo.number.parse(pageNumber);
            pageSize = dojo.number.parse(pageSize);

            setCurrentId(data["linkId"]);

            if(!submitRequest()){
                return;
            }

            console.debug(wc.render.getContextById('searchBasedNavigation_context').properties); //line 773
            var beginIndex = pageSize * ( pageNumber - 1 );
            cursor_wait();


            wc.render.updateContext('searchBasedNavigation_context', {"productBeginIndex": beginIndex,"resultType":"products"});
            this.updateHistory();
            MessageHelper.hideAndClearMessage();
        },

Upvotes: 0

Views: 543

Answers (2)

Harsh Vishwakarma
Harsh Vishwakarma

Reputation: 120

Here you are publishing the topic with name "showResultsForPageNumber" where "pageNumber", "pageSize", "linkId" are properties of object of your argument array.

See following link: ref1 ref2

Upvotes: 0

Dimitri Mestdagh
Dimitri Mestdagh

Reputation: 44685

It's part of the publisher/subscriber part of the Dojo framework and does not say anything about the executed AJAX request.

If you're not familiar with the publisher/subscriber pattern, then let's explain that first. To decouple certain components/parts of the application, this pattern is commonly used.

On one side, someone publishes information, while on the other side (= some other part of the application) someone listens to it.

In this case, the following data is published (= second parameter):

[{
  pageNumber: "4",
  pageSize: "15",
  linkId: "WC_SearchBasedNavigationResults_pagination_link_4_categoryResults"
}]

Obviously, not all subscribers in the application need to know about this data, so there's a topic system, in this case, the data is published to a topic called "showResultsForPageNumber"(= first parameter)

To know what happens next, you will have to look through the code for someone who subscribes to that topic. So somewhere in the code you will find something like this:

dojo.subscribe("showResultsForPageNumber", function(data) {
  // Does something with the data, perhaps an AJAX call?
});

TO answer your question, look in the code for something like: dojo.subscribe("showResultsForPageNumber", as it will tell you what happens next.

However, if you're just interested in the AJAX calls, it will be easier to check the network requests, if you're using Google Chrome/Mozilla Firefox/... you can use the F12 key to open your developer tools, then select the Network tab and activate if necessaray. Now click on the pagination controls and you will see a log of all network traffic and the request + response data.

Upvotes: 1

Related Questions