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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:41:12+00:00 2026-06-16T09:41:12+00:00

Im trying to get my javascript to read the JSON from a url on

  • 0

Im trying to get my javascript to read the JSON from a url on another page of my site. The plan is to have an image with a link that’s stored on that url and have that displayed on the front page of my site. I was able to do this before for a similar display so I thought it would be easy this time. For some reason, getJSON isn’t even reading the JSON from my URL and I’m pretty sure it’s correct, I modified the code from the previous display.

This code creates the JSON (in PHP):

function tf_feature_url_callback() {
  // get last row from the table
  $qry = 'SELECT * FROM tf_daily_featured_item ORDER BY fiid DESC LIMIT 1';
  $result = db_query($qry);
  $linkData = db_fetch_object($result);
  $data = array('link'=>$linkData->link);
  // encode the data as a json string
  $json_link = json_encode($data);
  echo $json_link;
}

And the JSON is displayed on a page as:

{"link":"test.com"}

This is the JavaScript:

// this is the url with JSON data
var urlURL = '/tf_feature/get_url';

$(document).ready(function() {
    $.getJSON(urlURL, function(data) {
        alert("TEST");
    });
});

Im not getting an alert so i’m pretty sure my javascript isn’t even entering the getJSON function.

Is there a limit to the amount of times you can call getJSON on a website? I’m calling it a few times already.

EDIT:

This is my callback (I’m using Drupal and this is a module)

// callback for the url
  $items['tf_feature/get_url'] = array(
    'title' => 'Featured Item URL Callback',
    'page callback' => 'tf_feature_url_callback',
    'access arguments' => 'access content',
    'type' => MENU_CALLBACK
  );
  • 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-16T09:41:13+00:00Added an answer on June 16, 2026 at 9:41 am

    Ok, first off I have to say that I winced at urlURL 😉 But moving on, there’s just not enough info here to fully diagnose your problem. Most likely your code isn’t getting run; perhaps the page has already loaded by the time your onReady runs? Then again, maybe not; without more info it’s hard to say.

    I highly recommend either getting the Firebug plug-in for Firefox, or using the Chrome (built-in) developer tools. Either of these will be able to tell you whether the AJAX request is happening or not, and if it is happening what’s coming back. Further more, you can add debugger lines to your code, and both those tool will pause when the hit those lines, allowing you to see what’s going on (you can inspect variable values and such).

    Try using one of those tools, and I really expect you’ll be able to debug this problem yourself.

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

Sidebar

Related Questions

I have written some JavaScript code that will read from the Google Maps API
I'm trying to get JavaScript to read/write to a PostgreSQL database. I found this
Possible Duplicate: Length of Javascript Associative Array I have a JSON that looks like
I’m trying to get a DOM element from JavaScript. Even though the ID is
I'm trying to get Jquery to read a json file, But unfortunately I can
I'm having trouble trying to get JavaScript and Regex to recognize an input from
I am trying to get one part of a URL to insert into another.
I'm trying to read Hebrew values from a .properties file and I get gibberish.
I have a URL http://myapp.com/get_data that returns an application/json Content-Type . When I browse
My Javascript alert's undefined when trying to read the following JSON string: [ {

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.