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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:56:26+00:00 2026-05-17T20:56:26+00:00

Im working on a drupal site that uses jQtouch (for iphone), and im trying

  • 0

Im working on a drupal site that uses jQtouch (for iphone), and im trying to make a search that doesnt reload the site. I think the javascript/ajax part isnt working. Im having problems finding out if the data from the php file is actually comming through, at the moment only the js that empties the search-results is working. Apperently jQtouch has ajax built into all forms or something. Does anyone have any interesting comments that could help me? btw this is the first time im using ajax and javascript

pensumsearch.php:

    $search = $_GET["search-text"];
    $result = db_query("SELECT nid FROM {node} WHERE title LIKE '%s' AND type = 'product_collection'", $search.'%');
    $noder = array();
    while ($record = db_fetch_object($result)) {
        $noder[] = $record;
    }
    $matches = array();
    foreach($noder as $row) {
        $node = node_load($row->nid);
        $res = db_query("SELECT tid FROM {term_node} WHERE nid ='$node->nid'");
        $termlink = (db_fetch_object($res));
        $matches[] = $node->title;

    }
header('Content-Type: application/json');
print json_encode($matches);


?>

search.js :


(function($){

    $(function(){

            $("#form").submit(function(event, info) {
                    var text = $("input[id=search-text]", this);
                    text.blur();

                    var results = $("#search-results", this).empty();
                    results.append($("<li>", {
                            "class": "arrow4",
                            text: 'Resultater "' + text.val() + '"'
                    }));

                    $.get("pensumsearch.php", { value: text.val() },
                            function(data) {
                                    $('#search-results').html(data);
                                    alert("Data Loaded: " + data);
                            }
                    );
                    return false;
            });
    });

})(jQuery);

  • 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-17T20:56:26+00:00Added an answer on May 17, 2026 at 8:56 pm

    It looks like you are using a stand alone php script, which means that Drupal shouldn’t be bootstrapped and you basically can’t use any of Drupal functions, unless you already bootstrap Drupal without showing. If you do bootstrap Drupal, there’s not much point in using a stand alone PHP script.

    Another thing is that you should put the % for the like query directly in the sql instead:

    WHERE title LIKE '%s%' ... $search
    

    Another thing is that you are doing:

    $('#search-results').html(data);
    

    Which should work, but shouldn’t be pretty since it’s a json encoded string you are inserting. You might considder using $.getJSON which will convert the data into json format.

    You might also consider debugging your php script, or use firebug to see if you get the expected output.

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

Sidebar

Related Questions

I'm working at a company that uses Drupal 6 to host documentation for it's
While working on an existing Drupal site I've noticed a strange glitch that causes
I've got a Drupal site which uses a custom field for a certain type
I'm working on a drupal 6 site at mydomain.com/drupalsite, and the designer has put
I'm adding additional languages to a Drupal site that I'm building. Getting the translation
I am working on developing a drupal site right now. I have created a
I'm interested in creating a custom theme for a Drupal site I'm working on.
I have a Drupal site with pages indexed by a Google Mini search appliance.
I'm working on a drupal site where I allow users to login while at
I'm currently working on a Drupal site (I'm fairly new to Drupal) and need

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.