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

  • Home
  • SEARCH
  • 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 7676169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:08:17+00:00 2026-05-31T17:08:17+00:00

I have my php coded page on one server that returns a json result.

  • 0

I have my php coded page on one server that returns a json result.
php file called: getInfoData.php and the return is as below.

  echo json_encode($v);

No I can use $.getJSON(??) to read the json and run it all on the same sever fine, but I need the php page to be on a different sever than the js page calling it.

But then I get then when I do I get the cross domain issue.

So I changed the code to use the following (jsonp):

  $.ajax({
    url: 'FILE_LOCATION_ON_ANOTHER_SERVER',
    type: 'GET',
    crossDomain: true,
    dataType: 'jsonp',
    success: function() { console.log("Success"); },
    error: function() {console.log('Failed!'); }
});

but I do not see anything I just get the following with my console:

  http://www.THEURL.com/FOLDER/FILENAME.php?callback=jQuery171013088115444406867_1332256223342&_=1332256223343

and a message saying failed!.

What am I doing wrong and how if at all can I fix this?

Thanks

  • 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-05-31T17:08:18+00:00Added an answer on May 31, 2026 at 5:08 pm

    JSONP isn’t actually JSON. It’s a bit of a “hack”. JSONP is actually a JavaScript file, that gets downloaded and ran.

    In your PHP page, you should be passed a callback parameter. You need to “wrap” your JSON in it. It should look like this:

    func({json: data})
    

    So, your PHP should look like this:

    echo $_GET['callback'] . '(' . json_encode($v) . ')';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page coded in PHP. This page is for posting a
I have a page that is accessed via a URL like this: http://power-coder.net/Test/something.php?id=3#Page1 I
I currently have one server with nginx that reverse_proxy to apache (same server) for
I have a CodeIgniter app that works on one server (IIS 6) just fine.
I have a php page and i have some javascript code to have a
i have tried this code to redirect a php page.but it s not working
I have some PHP code that generates dynamic tables of data on the fly.
I have some PHP code that is designed to make a spreadsheet with formulas
I have some PHP code that generates a calendar and then outputs html to
I have a PHP application that makes extensive use of Javascript on the client

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.