Search Results

Search found 1 results on 1 pages for 'randomdev'.

Page 1/1 | 1 

  • how do you get the response back into the instance of the object?

    - by randomdev
    If you've written a class in JavaScript that calls a remote service's API, and that remote API offers a callback, how do you get the response back into the instance of the object that made the request? I'll try to give you a very basic example FOO for making cross domain calls to BAR service which offers a callback. Please ignore the usual security concerns, (I own both servers). function FOO() { this.response = null; this.execute = function(url) { var script = document.createElement('script'); script.src = url; document.getElementsByTagName('head')[0].appendChild(script); } this.catch = function(response) { this.response = response; } } var sample = new FOO(); sample.execute('http://barservices.com/sample/?callback={ plshelphere: this.catch}'); I have a way to make this work, but I'm curious if there is an "accepted approach" here. Anyone have thoughts for me?

    Read the article

1