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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:53:54+00:00 2026-05-30T12:53:54+00:00

Not sure where I might have went wrong the code seems fine to me,

  • 0

Not sure where I might have went wrong the code seems fine to me, and I know the file.php -> mod_rewtite -> file.json works as I have tested JSON response from this file via jQuery. In any event the following code bit attached triggers the error response right away instead of going truth the JSON request any guesses why?

sidenotes: I am using latest Dojo Toolkit 1.7.1 from Yandex mirror: http://yandex.st/dojo/1.7.1/dojo/dojo.js

and here is the code for the JSON which does not work

<script type="text/javascript">
    require(["dojo/_base/xhr", "dojo/dom", "dojo/_base/array", "dojo/domReady!"],
    function(xhr, dom, arrayUtil) {

        // Keep hold of the container node
        var containerNode = dom.byId("content");

        // Using xhr.get, as we simply want to retrieve information
        xhr.get({
            // The URL of the request
            url: "file.json?path=<?php echo $_GET['path']; ?>&callback=?",
            // Handle the result as JSON data
            handleAs: "json",
            // The success handler
            load: function(jsonData) {
                // Create a local var to append content to
                var html = "";
                // For every news item we received...
                arrayUtil.forEach(jsonData, function(item) {
                    // Build data from the JSON 
                    html += "<div class='product' data='" + item.path + "'>";
                    html += "<div class='like'></div>";
                    html += "<img src='thumb.php?q=100&w=298&h=238&a=t&src='" + item.thumb + "' width='298' height='238'/>";
                    html += "<div class='title'>" + item.name + "</div>";
                    html += "<div class='description'></div>&nbsp;<strong>Filesize:</strong>" + item.size + "<div style='clear:both;height:8px;'></div>&nbsp;about" + item.date + " ago<div style='clear:both;height:8px;'></div></div><div class='clear'></div></div>";
                });
                // Set the content of the news node
                containerNode.innerHTML = html;
            },
            // The error handler
            error: function() {
                containerNode.innerHTML = "News is not available at this time."
            }
        }); 
});
</script>

Also here is the file.php -> file.json code bit in even you need it, but as I said I do not suspect it as it works perfectly with jQuery

<?php

$dir = $_GET['path'] . "/";

function time_since($since) {
    $chunks = array(
        array(60 * 60 * 24 * 365 , 'year'),
        array(60 * 60 * 24 * 30 , 'month'),
        array(60 * 60 * 24 * 7, 'week'),
        array(60 * 60 * 24 , 'day'),
        array(60 * 60 , 'hour'),
        array(60 , 'minute'),
        array(1 , 'second')
    );

    for ($i = 0, $j = count($chunks); $i < $j; $i++) {
        $seconds = $chunks[$i][0];
        $name = $chunks[$i][1];
        if (($count = floor($since / $seconds)) != 0) {
            break;
        }
    }

    $print = ($count == 1) ? '1 '.$name : "$count {$name}s";
    return $print;
}

$dh = opendir($dir);
$files = array();
while (($file = readdir($dh)) !== false) {
    if ($file != '.' AND $file != '..' ) {
        if (filetype($dir . $file) == 'file') {
            $files[] = array(
                'id' => md5($file),
                'name' => htmlentities(md5($file)),
                'size' => filesize($dir . $file). ' bytes',
                'date' => time_since(date("ymd Hi", filemtime($dir . $file))),
                'path' => $dir . $file,
                'thumb' => $dir . 'small/' . $file
            );
        }            
    }
}
closedir($dh);

    $json = json_encode($files);

    $callback = $_GET['callback'];
    echo $callback.'('. $json . ')';

?>
  • 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-30T12:53:55+00:00Added an answer on May 30, 2026 at 12:53 pm

    In the url, you are fetching file.json – that seems to be erroneous
    Should that really be file.php?

    url: "file.php?path=<?php echo $_GET['path']; ?>&callback=?",
    

    also make sure the path is correct – you can examine the Net tab in firebug to see the request it is trying to send

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

Sidebar

Related Questions

I have this bit of code which I am not sure if it is
I have a jQuery code as follows; $(#+iframeId).attr(src,url); //works perfect $(a[target=+iframeId+]).attr(href, url); //does not
The tags might not be accurate since I am not sure where the problem
I'm not sure if this is possible in one mysql query so I might
I'm not sure how to look for this online... I think they might be
This might be iPhone specific, I'm not sure. The compiler doesn't complain when building
Not sure what exactly is going on here, but seems like in .NET 1.1
Not sure if this is intended behavior or a bug or a wrong function
Not sure how to word this algorithm question, actually. I have toggle buttons in
I have been trying to search for this and am not sure I am

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.