Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8777607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:18:56+00:00 2026-06-13T19:18:56+00:00

I have an app that I’m writing in Javascript for use with Phonegap, that

  • 0

I have an app that I’m writing in Javascript for use with Phonegap, that retrieves a JSON encoded string from a PHP script on my server.

Is it possible to retrieve this JSON encoded string from the PHP in Javascript when it’s a cross domain request?

What I’m currently using is Yahoo’s YQL, which retrieves the string through a jQuery AJAX, but I don’t want to have to rely on Yahoo for their service, especially since it’s been very flakey today in terms of uptime.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:18:57+00:00Added an answer on June 13, 2026 at 7:18 pm

    For Cross Domain GET’s, if you own the endpoint, I recommend modifying it to use JSONP

    Because browser <script> tags can load scripts from different domains, it is one way to work around cross-domain issues, with little worry about cross-browser support. It does pose some potential Cross-Site-Scripting Issues (I recommend reading the wiki page I linked above) that you should be aware of.

    Make JSONP API calls is super easy if you use jQuery, but it’s still simple enough to do with strict javascript by dynamically injecting the <script> tags yourself, setting the src attribute to your API endpoint, and creating your own callback function that is invoked once the call is successful.

    Modify your server endpoint to take a callback parameter. Wrap your json response with the callback.

    e.g. (not real code)

    //example api url
    //http://tempuri/apiendpoint?callback=foo 
    
    //example url handler (not in PHP)
    app.get('/apiendpoint',function() {
      return query.callback + '({"json": "value"});'
    });
    

    If you’d rather not support JSONP, you can enable Cross Origin Resource Sharing (CORS). Both iOS and Android webbrowsers support it. In order to add support for CORS, you’ll need to modify your endpoint to send the appropriate headers:

    'Access-Control-Allow-Origin'
    'Access-Control-Allow-Methods'
    'Access-Control-Allow-Headers'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a app that loads some json from my php web service. This
I have an app that received JSON data from the server. Currently when I
I have a app that receive a feed from a server through json. I
I have an App that downloads and displays images from URL's. This works fine
I have an app that needs to process some packets from a UDP broadcast,
I have an app that I want to use to store different people's data.
I have an app that calls to a server and gets a long string
I have an app that can show a stream of tweets from a twitter
I have an app that would benefit from google-style autocompletion while filling in an
I have an express app that has a bunch of static javascript files that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.