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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:14:50+00:00 2026-05-12T07:14:50+00:00

Right now I’m loading nodes with jquery’s $.ajax. By that I mean I simply

  • 0

Right now I’m loading nodes with jquery’s $.ajax. By that I mean I simply enter in the node url and then load the whole page.

That’s probably ridiculous and totally incorrect way to do it. How do I fetch a specific field in a node without loading the kitchen sink?

Thanks

I also see this module:

http://drupal.org/project/js

Am I to use that?

Edit: An example of what I’m doing is like this:

$.ajax({
    url: node/500,
    success: function(response){
        var ajaxresult = $("<div/>").append(
        response.replace(/<script(.|\s)*?\/script>/g, "").find('#field-want-this-field').html();
        $someplace.append(ajaxresult);
    }
});

This loads the entire page first, and then grabs the field. Since it’s on the same site, surely there’s a better method?

Thanks!

  • 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-12T07:14:50+00:00Added an answer on May 12, 2026 at 7:14 am

    What you are doing is a waste, but it will require a bit of work to get this to work. What need to do, is to setup a function that can make the queries for what you need, fx one that would take the node id and field name and then return the field text. There are two ways of doing this.

    1. node_load (slow but simple)
    2. querying the db directly for the field that contains the data (fast but more complicated)

    One problem is general, is that fields sometimes use delta if there are more than one value for the same field. This makes it a bit more complex to get the data you need. This is also decided through the admin interface which means a site admin could possible break this functionality if you don’t take care. Another thing is that the names of the fields also is created through the admin interface (unless you have created a node type with some fields in your own module).

    Then thing that makes querying the db yourself difficult, is that CCK have different ways of making tables to save the data in, and you have to figure out exactly how this works, to make this generic.

    In the end, if you create your own function you could do something like this:

    <?php
    function get_date($args) {
        // get the data as $data
        return drupal_json $data;
    }
    

    and your ajax.

    $.getJSON('mymodule/node/nid/field_name', function(php_data) {
        $someplace.append(php_data);
    });
    

    Drupal will cache your get requests, so you have to use different urls to take advantage if that.

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

Sidebar

Related Questions

Right now, I have a jQuery UI pop-up dialog that reads from an external
Right now, I keep all of my projects on my laptop. I'm thinking that
Right now I have an SSIS package that runs every morning and gives me
Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName
Right now I have an application that loads a bunch of thumbnail images into
Right now I've programmed a method for use in a swing program that is
Right now, I only understand that Global indexes on a partitioned table are for
Right now I'm using the jQuery selector $('foo+bar') . Since I already have $('foo')
Right now I have a simple class that handles the parsing of XML files
Right now we have a dll file that contains all the database calls and

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.