jquery - CakePHP returning HTML from remote site page to view through AJAX call -


i trying add form request page return html user through ajax call. using cakephp framework , built in helpers ajax request. i've tried multiple ways of performing request , returning html comes response div. appears there heavy issues prevent calling external page , returning it.

i know query working correctly because can copy firebug request location browser , proper formatted response page.

from searching i've done i've gathered aren't allowed cross browser requests , have sort of redirect controller. i've tried several things without success there well. if change ajax request local controller action work. need display request response external page returns data server. have control of both servers , pages.

what proper way set in cakephp?

i can't quite understand you've tried, yes, in simple terms can't use ajax request content different domain. can use php proxy, think you're suggesting.

so, if have things controller 'stuff' action, ajax requests content cakephp site this:

$.getjson('/things/stuff', function(data) {     console.log(data); }); 

you 'stuff' action use php external content (using file_get_contents, example) , return ('data' above) ajax callback.

function stuff() {     $content = file_get_contents('http://www.stuff.com/thing');     $this->set('content', $content); } 

that should want.

toby


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -