I am trying to load a form via ajax, here is the code i use:
JS:
bigPopupBut.click(function () {
jQuery.ajax({
url: "http://site/group_create",
dataType: "html",
success: function (data) {
bigPopup.append(data);
}
});
})
The group_create is a PHP script that returns me a form, here is the code i used:
$node_type = 'group';
$form_id = $node_type . '_node_form';
$node = new stdClass();
$node->uid = $user->uid;
$node->name = $user->name ;
$node->field_city['und']['0']['value'] = $user->field_city['und']['0']['value'];
$node->field_country['und']['0']['value'] = $user->field_country['und']['0']['value'];
$node->type = $node_type;
$node->language = LANGUAGE_NONE;
$node->path = '';
node_object_prepare($node);
$return=drupal_get_form($form_id,$node);
return $return;
The Problem i have is that the PHP callback doesn't just return me the form, but a whole page, with headers, body, so when i append it with JS i get a duplicate of the whole page in my bigPopup DIV.
What am i doing wrong ? how could i just get the form without the surounding page?
Thanks all for the help.