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 7601225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:07:04+00:00 2026-05-30T23:07:04+00:00

I am working on a seemingly basic mobile app (first). But I want to

  • 0

I am working on a seemingly basic mobile app (first). But I want to enable the application to request information from our ‘head’ server. To make sure it has the latest information.

I’m currently running a jQuery script like this.

$.ajax({
        url: 'http://www.domain.com/list.php',
        dataType: 'json',
        crossDomain: true,
        success: function(data) {

            // Remove all content first
            $(contentId +' li').remove();

            // Load Data
            $.each(data.items, function(index, list){
                $(contentId).append('<li><a href="details.html?id=' + list.homeId + '" >' + list.name + '</a></li>\n');
            });

            // Reload View
            $(contentId).listview('refresh');

        }, 
        error: function(jqXHR, textStatus, errorThrown) {
            console.log('Error: '+ jqXHR + textStatus + errorThrown);
        }
    });

And actually on that LIST.PHP file, it does return a JSON string. But what I did for security was by adding this as a header

header("Access-Control-Allow-Origin: *");

Or I could change * to a domain/url to add better security. But if I don’t add that header() code in their, my javascript breaks and won’t run properly.

I guess what i’m truly wondering is, am I doing this properly? or is there a better way to do this? I have tried JSONP, but I can’t seem to get that to work for cross domain.

Is my solution sound? or total crap? Any thoughts or direction would be greatly appreciated!

  • 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-30T23:07:06+00:00Added an answer on May 30, 2026 at 11:07 pm

    I think you should look into JSONP. It’s not that hard. On the client side, jQuery already handles it out of the box, just append a ?callback=? to the URL. On the server, instead of just responding with JSON, e.g.:

    {
      "foo": "bar"
    }
    

    Look for the query parameter callback, and if it exists, wrap your JSON output in a function call with the name being the value of the callback parameter, so, for callback=foo:

    foo({
      "foo": "bar"
    })
    

    When responding with JSONP, send Content-Type: text/javascript. This should work without setting Access-Control-Allow-Origin or anything like that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB.
I'm working on an app that, from the Main.mxml, opens one or many Window.mxml
First off, I'm working on an app that's written such that some of your
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
Some code a production server which uploaded files has seemingly stopped working with the
I have been working on this problem for a while but still no joy.
I have a Websphere Portal application containing several portlets for which I'm currently working
I'm perplexed as I'm not the method below is seemingly NOT working when looking
I'm working on my first real ASP.NET MVC project and I've noticed that the
I'm working on a WPF application that sometimes exhibits odd problems and appears to

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.