ghostJago
ghostJago

Reputation: 3434

jQuery event when JSON is received - one time URL

I'm trying to scrape a site that uses lots of ajax effects to show data in a table.

There is some data returned via JSON when you interact with the site.

I know the URL and how to construct it but the server returns a HTTP 410 status if I try and re-request this JSON (I guess the server is expiring the data).

I have one chance to capture the data and I'm looking for a jQuery function, something like onJSONResourceReceived would be nice so that I can catch the response and store it in a variable.

Either a callback or a way to cache the data in a variable would be great.

Or if there is already a variable that stores all JSON resource already received in memory, that is even better.

All the functions I've looked at are for situations where you know or can re-request the URL.

This question is similar but for CasperJS: How to get the response after a POST request in CasperJS

Upvotes: 1

Views: 105

Answers (1)

BenG
BenG

Reputation: 15164

Look at the $.ajaxSuccess

Attach a function to be executed whenever an Ajax request completes successfully.

$(document).ajaxSuccess(function( event, request, settings ) {

});

Upvotes: 1

Related Questions