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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:49:43+00:00 2026-06-17T22:49:43+00:00

..going to try this another way.. Links to another page are not very useful

  • 0

..going to try this another way..

Links to another page are not very useful to me.. I’ve looked at most of them and have not been able to adapt them to what I need.

I’m not familiar with ajax or jQuery.

I could really use some help with detailed EXAMPLES of code that works with regard to this particular question. thanks in advance..

I have this piece of code called: JSON_generator.php

<?php
require_once 'EasyWebFetch.php';

$callback = isset($_GET['callback']) ? $_GET['callback'] : 'mymap.weatherhandler';
$station = isset($_GET['rid']) ? $_GET['rid'] : 'FWS';
$product = isset($_GET['product']) ? $_GET['product'] : 'NCR';
$nframes =  isset($_GET['frames']) ? $_GET['frames'] : 10;

if (strlen($product) != 3 || strlen($station) != 3) { exit; }

// fetch directory listing
$wf = new EasyWebFetch;
if (!$wf->get("http://radar.weather.gov/ridge/RadarImg/$product/$station/")) {
  print $wf->getErrorMessage();
  exit;
}
$page = $wf->getContents();
// echo $page."\n\n";

$size = preg_match_all( "/href=\"({$station}[\d_]+{$product}\.gif)\"/" , $page, $match);
$files = $match[1];

$nframes = min(count($files), $nframes);
$files = array_slice($files, -$nframes);

echo $callback."\n(\n{\ndirectory:\n[\n";
for ($i=0; $i < $nframes; $i++) {
  echo "\"ridge/RadarImg/$product/$station/$files[$i]\",\n";

}
echo "]\n}\n)\n;"

?>

When called from the command line like this…

http://example.com/mypath/JSON_generator.php?&?callback=CallBack&product=NCR&rid=JAX&frames=5

But what I really need is to have those .gif path/file/names “available” from a javascript function that called the php in the first place.** They need to be accessible as items in an array.

I can’t figure out the javascript function call to do that..

.. something like this but obviously not this ..

function Feed (whichproduct, whichsite) {
 var filelist = [];
 var siteimages = filelist("http://example.com/mypath/JSON_generator.php?&product=whichproduct&rid=whichsite&frames=5");
..then..
//alert (filelist [1]); .. should return something like  "ridge/RadarImg/NCR/JAX/JAX_20130128_2354_NCR.gif"
}

Obviously, I’m a beginner so complete answers would be much more valuable to me than just code snippets..

Bottom line:

I need a javascript function that can pull each of those .gif names from the php script and bring them back into a javascript “var” that I can use elsewhere in the html file.

Thanks,
Dennis

edit.. edit removed.. figured it out..

  • 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-17T22:49:44+00:00Added an answer on June 17, 2026 at 10:49 pm

    I’ll answer using jQuery initially, since that makes things very easy, but I’ll update in a moment with the vanilla Javascript implementation.

    In your Feed function, make an AJAX call using jQuery’s convenient $.ajax method.

    function Feed (whichproduct, whichsite) {
        $.ajax({
            "url": "http://mysite.com/mypath/JSON_generator.php?&product=whichproduct&rid=whichsite&frames=5"
            "type": "GET",
            "dataType": "json",
            "success": function( data, status, xhr ){
                alert( data[1] );
            }
        });
    }
    

    In your PHP, use json_encode on a well-formed PHP array (just push to an array() instead of echoing the urls and commas and such directly).

    At the very end, print json_encode( $yourArray ).

    Update for Vanilla Javascript:

    Rather than copying the (extensive) javascript here, I’ll just link to a nice SO answer by @Richard H. Hope that helps if you’re not looking at using jQuery!

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

Sidebar

Related Questions

I'm going to try and explain this as simply as I can, it's most
This is very hard to explain but I'm going to try. We run a
I'm going to try to explain this best I can I will provide more
Ok, I'm going to try to make this more clear because my last question
I been going through this tutorial and it looks really good. So I went
Hey guys I have this page : PS: this is temp data, so it
Most resources suggest using onclick handler with trackEvent() for tracking outgoing links. BUT this
I'm going to try and explain this without showing any code because I don't
Let me try this again, I'm going to leave out the exact data/example and
I have a C (not C++) struct that goes like this typedef struct mystruct{

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.