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

How do I reserve JSON data for .getJSON calls?

  • February 2, 2016
  • 1 reply
  • 1646 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

    Legend
    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.

    Legend
    February 2, 2016

    JSONP is a pre-CORS technology. The API provider should have info on this if they support it as it requires special handling on their end. If they don't already support a JSONP API, CORS is MUCH easier to support and in my opinion CORS is a much more secure option than JSONP (only data returned from the host as opposed to javascript wrapped data). Hopefully they support CORS as this would be your easiest and most secure approach.