javascript - Send an Ajax request in CasperJS and loop through results -
i trying fetch json values(mainly urls) call , assign variable. ultimlately loop through values , open each url casper. however, seen have incorrect concept on fetching values through ajax call casperjs. read through documentation dont seem understand why still getting error referenceerror: can't find variable: __utils__?
casper.start(); var url = "http://dev.web-ui.com/generate.php";  casper.then(function(url) {     var results = __utils__.sendajax(url, "get"); });  casper.run();      
you have @ least 2 problem:
the
urlparameter not url, last loaded page resource object contains url.__utils__not available outside of page context. can require if want, won't fix problem, because dummydocument.locationoutside of page context has not same domain url want query, request may fail due cross-domain restrictions. it's best in page context.
example code:
casper.then(function(resource) {     var results = this.evaluate(function(url){          return __utils__.sendajax(url, "get");     }, resource.url);     this.echo(results); });      
Comments
Post a Comment