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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:22:21+00:00 2026-06-09T23:22:21+00:00

I am trying to receive a node form via ajax in Drupal. Normally I

  • 0

I am trying to receive a node form via ajax in Drupal.

Normally I should have created an ahah triggered button that brings and displays nicely the json data.
I did it for testing and it worked very nicely with the php code below.

But what i need is to dynamically create custom ahah triggered links with javascript. And these custom links to act like ahah buttons and call the callback function that brings the node form.

On the server side the callback function which send the json data is this:

function get_lesson_form($nid) {
    global $user;  

    $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => 'lesson');
    $form_id = 'lesson_node_form';

    // Initialize settings:
    $file = drupal_get_path('module', 'node') . '/node.pages.inc';
    include_once './' . $file;

    $rendered_form = drupal_get_form($form_id,$node);
    $javascript = drupal_add_js(NULL, NULL);

    drupal_json(array(
        'status'   => TRUE,
        'data'     => $rendered_form,
        'settings' => call_user_func_array('array_merge_recursive',$javascript['setting']),
        )
    );
}

I looked a little bit how Drupal’s ahah.js deals with retrieving and displaying the json content and i created an ajax call below that simply takes tha json data and appends it.

$.ajax({
    url : '/fcrp_form/nid',
    success : function(response) {
        console.log(response);

        var form = Drupal.parseJson(response);
        var target_wrapper = $('#event-edit-container');
        var new_content = $('<div></div>').html(form);

        target_wrapper.empty().append(new_content);
        Drupal.attachBehaviors($('#event-edit-container'));
    },
    error : function(response, error) {           
        console.log(response);
        console.log('Error: '+ error);
    },
    type: 'POST',
    dataType: 'json',
});

The problem is that i always receive a parseerror message and the response object is like a mess.
I cannot bring the json data successfully and i don’t know how this error is occured.

Notice: This happens when the $data has html code. If it has plain text it returns no errors.

Also when I tested with the normal ahah button (the Drupal way), the jquery version 1.3.2 was used, but in my case I use 1.7.2 version.

Any help would be really appreciated.

  • 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-09T23:22:23+00:00Added an answer on June 9, 2026 at 11:22 pm

    Sorry for the late answer. Yes, I used Drupal 6.

    In the end, the problem turned out to be the different versions of jQuery.
    So I used jQuery.noConflict() and everything seemed to work fine.

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

Sidebar

Related Questions

I have a basic Node.js app that I am trying to get off the
I am trying to receive an image from the Android Gallery via an ACTION_SEND
I'm trying to start Erlang slave node on cluster and I receive bash: erl:
I have some XML that I am trying serialize like so: string Value =
I receive this error when trying to run a node.js server. I recently migrated
i have a proyect that im trying to finish i wanna upload images i
So I'm building a multipart form uploader over ajax on node.js, and sending progress
I am trying to make a Node.js file uploader with a AJAX progress bar.
We have a set of views (quite a few) that we're trying to implement
Trying to receive a callback from clicks on node. Currently the example expands a

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.