Skip to main content
2Charlie
Inspiring
February 2, 2016
Question

How do I reserve JSON data for .getJSON calls?

  • February 2, 2016
  • 1 reply
  • 1642 views

I'm able to use cfhttp to query the data. However, I'm not sure how to reserve this data for my jQuery .getJSON() calls. Since I can't do a CORS call with JavaScript, I believed an alternative is to use ColdFusion cfhttp calls. Any suggestion is much appreciated.

    This topic has been closed for replies.

    1 reply

    Brainiac
    February 2, 2016

    Not exactly sure what you are asking. I think you are asking how to use CF as a proxy server. This in and of itself is fairly easy but I think I would need to know more specifics as to why as simply proxy services might not be the best solution. Why can't you use CORS? Assuming CORS is really not an option, JSONP would be the next "standard" way to accomplish what I think you are asking. Need more details...

    2Charlie
    2CharlieAuthor
    Inspiring
    February 2, 2016

    Thanks, Steve. I probably don't use the correct terms but yes. I'm exploring other alternatives and I came across a thread in jQuery to suggest using CF as a proxy server. However, I have never done much with ColdFusion. I'm in the process of asking if the API provider have their servers CORS enable. If not, then I may have to resort to CF proxy server if there are no other better alternatives. Will you provide links/information on the JSONP option? I have tried using .getJSON and came across the No 'Access-Control-Allow-Origin' header is present on the requested resource error; thus, I'm in the hunt for a solution.

    Thanks again.

    2Charlie
    2CharlieAuthor
    Inspiring
    February 4, 2016

    I guess I would need to know more of what you are trying to do. Making it available via an AJAX call can let you do client-side "do something" logic but depending on the project, the "do something" may be easier and more straight forward to do server-side. The short answer is: It depends.


    I do not want to reveal the API key to the public and do not want the page to refresh/reload every time there is a change in the page.  Are there any samples of CF proxy server that  I can take a look?