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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:51:27+00:00 2026-05-31T17:51:27+00:00

Hi I am trying to run an ajax query using jquery. If I use

  • 0

Hi I am trying to run an ajax query using jquery. If I use a locally stored .txt file I get no problems. The problem comes whenever I try to query a php generated json. Here it is the code:

$('#find').click(function(){
$.getJSON('http://localhost/public/ProductCatalog/searchindex/txt.php', function(data) {
var items = []; 
$.each(data, function(key, val) {
        pushStr = '<div class="prod-container">';
        pushStr += '   <div class="prod-image-container"><img class="prod-img" src="' + val['foto'] + '"/></div>';
        pushStr += '    <div class="prod-desc-container">' + val['title'] + '</div>';
        pushStr += '    <input class="id" type="hidden" value="' + val['id'] + '"/>';
        pushStr += '    <input class="title" type="hidden" value="' + val['title'] + '"/>';
        pushStr += '</div>';
        items.push(pushStr);
    });

    items.push('<div style="clear:both;"></div>');
    $('#prod-body').html(items.join(''));
    $('img.prod-img').each(function (index, element){
        fitImage(element, 75, 110);
    });
    makeDraggable();
});
});

So if I create a file.txt copy/pasting the same info I generate from http://localhost/public/ProductCatalog/searchindex/txt.php and use it as a parameter, then I get the content. Howerver nothing gets executed when I run the code as is.

file.txt example:

{
    "item1": {
        "foto": "item1.jpg",
        "title": "Teclado roland fantom-g8  las teclas con contrapeso",
        "id": "1",
        "price": "56090.25"
    },
    "item2": {
        "foto": "item2.jpg",
        "title": "Teclado roland v-piano  lo cambia todo",
        "id": "1",
        "price": "85501.79"
    },
    "item3": {
        "foto": "item3.jpg",
        "title": "Teclado roland ax-synth  teclado 49 teclas (dinÃ",
        "id": "1",
        "price": "13034.05"
    },
    "item4": {
        "foto": "item4.jpg",
        "title": "Teclado roland fantom g-6 fuente de sonido avanzada",
        "id": "1",
        "price": "39989.14"
    },
    "item5": {
        "foto": "item5.jpg",
        "title": "Teclado gw-8l roland gw-8l -bstock",
        "id": "1",
        "price": "11627.32"
    },
    "item6": {
        "foto": "item6.jpg",
        "title": "Teclado disney",
        "id": "1",
        "price": "605.00"
    }
}

here is the php code:

    // action body usinf zend framework
    $this->getHelper('viewRenderer')->setNoRender();
    $index = Zend_Search_Lucene::open('/data/prod-catalog');
    $results = $index->find('teclado roland');
    $first = $this->_request->getParam('first');

    header('Cache-Control: no-cache, must-revalidate');
    header('Content-type: application/json');

    $i=1;

    echo '{';
    foreach ($results as $result){
        echo '"item'.$i.'": {'."\n";
        echo '    "foto": "'.$result->foto.'",'."\n";
        echo '    "title": "'.ucfirst(strtolower($result->titulo)).'",'."\n";
        echo '    "id": "'.'1'.'",'."\n";
        echo '   "price": "'.ucfirst(strtolower($result->precio)).'"'."\n";
        echo ($i<count($results) && $i<6)? '},'."\n": '}'."\n".'}'; 
        $i++;
        if($i==7){
            break;
        }
    }
  • 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-31T17:51:28+00:00Added an answer on May 31, 2026 at 5:51 pm

    I found it, it was a security issue. I was running the html with the js functionality in local and the server would not allow that. Once I ran it in the server it was solved.

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

Sidebar

Related Questions

I'm trying to use jQuery to run an AJAX query on a specific port:
I've been trying to get this really simple example of using AJAX with JQuery
The Problem I am trying to run some ajax on one my pages for
How can I use AJAX to run a PHP file when the page is
I am trying to use jQuery ajax to send a json object to a
I have been experimenting and trying to learn JQuery, using AJAX to consume a
I get the above exception after downloading and trying to run the latest Ajax
I am using Codeigniter and trying to use the jQuery autocomplete with it. I
i am trying to use the Jquery ajax function to call a php page
I'm trying to run .ajax and insert a data element from the onClick of

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.