javascript - Are ajax calls possible without a browser? -
i'm trying create javascript tests using mocha , chutzpah, means tests done browserless. issue i'm running ajax calls returning empty string, following not work:
$.ajax({ url: "http://www.something.com/", //ajax events async: false, }).done(function(data) { test = data; });
here, test set '', i've tried many different combinations of ajax parameters such async
, type
, datatype
, success
, etc.
so question is, ajax calls possible without browser?
i took quick @ chutzpah , seems it's implemented on top of phantom.js. you're not running test without browser. on contrary, you're running test inside webkit based browser - albeit 1 without gui.
since test running inside browser, browser restrictions apply. includes same-origin-policy. depending on how chutzpah loads test script ajax call may fail.
if chutzpah loads test page disk same-origin-policy fails. don't know chutzpah if it's possible make load test page url (you can run test server on localhost).
you can disable security features in phantom.js passing --web-security=false
on command line. not sure how you'd mocha , chutzpah option can investigate.
Comments
Post a Comment