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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:22:38+00:00 2026-05-29T15:22:38+00:00

I call a PHP script on my other server to pull database info and

  • 0

I call a PHP script on my other server to pull database info and it returns a JSON array. But ajax calls cant call cross domain so I’m running it through a local PHP script that makes a CURL call to the remote PHP script. That script returns a JSON array to the curl script (getURL.php) and that echos back. writing the data returned to the console looks correct but it was counting EVERY character as an array element. So I thought maybe it was coming back as text. But adding $.parseJSON(data) throws an error. Removing it says arr length is 170. Any ideas?

function getPrograms() {

    var data = "url=http://www.wdctravel.com/co-op/getPrograms.php";
    $.ajax ({
        url: "getURL.php",
        data: data,
        success: function(data) {
            var arr = $.parseJSON(data);
            postPrograms(arr);
        }
    });
}       

function postPrograms(arr) {
    var len=arr.length;
    alert (len);
    for(var i = 0; i < len; i++) {
        if (i % 2 == 0) {
            $('#programs tr:last').append("<tr></tr>");
        }
        $('#programs tr:last').append('<td><input type="text" size="3" name="CoOpID~' + arr[i]['id'] + '" /></td><td>' + arr[i]['name'] + '&nbsp;<span style="color: red;"><span id="cs' + arr[i]['id'] + '">' + arr[i]['remain'] + '</span> spots left.</span></td>');
        var c = $("#programs tr:last td").length;
    };
}
  • 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-29T15:22:39+00:00Added an answer on May 29, 2026 at 3:22 pm

    Check if your JSON response is malformed.

    Passing in a malformed JSON string may result in an exception being
    thrown. For example, the following are all malformed JSON strings:

    {test: 1} (test does not have double quotes around it). {‘test’: 1}
    (‘test’ is using single quotes instead of double quotes). Additionally
    if you pass in nothing, an empty string, null, or undefined, ‘null’
    will be returned from parseJSON. Where the browser provides a native
    implementation of JSON.parse, jQuery uses it to parse the string. For
    details on the JSON format, see http://json.org/.

    http://api.jquery.com/jQuery.parseJSON/

    If you have control over the remote server, I’d suggest using JSONP.
    http://en.wikipedia.org/wiki/JSONP

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

Sidebar

Related Questions

I have a script called api.php on my server. I call it from other
I have a php script that is waiting for ajax calls at www.mydomain.com/file.php The
I just finished coding my first jquery ajax call page. It calls a php
I'm trying to cache JSON content generated by a php script from database. However
How can I call a PHP script from a Perl script and get its
So I call this PHP script from the command line: /usr/bin/php /var/www/bims/index.php projects/output and
I have to call an existing AMF Method in a PHP (or Perl) Script
Is there any way to have PHP automatically call a function, before a script
I want to call a PHP file but want to pass an argument to
I want to call a php script every minute. My scriptruntime on my webserver

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.