Ajax: Still don't get it

Discussion relating to version 1.3.x and 1.4.x

Ajax: Still don't get it

Postby Hansi » Thu Mar 08, 2012 8:26 pm

Hey!

I read a lot of tutorials but still don't get my ajax-function working:(

I've got a drop-down-field, whose values are id's for users.
I've embedded a user-form in my "parent" form and now want, to change the labels in the embedded "user-form" when changing a drop-down-field.

my routing.yml:
update_user_form:
url: /user/updateuserForm
param: { module: provider, action: updateUserForm }

the action is called "executeUpdateUserForm" and does this:
$id = $request->getParameter('user_to_change');
$user = Doctrine_Core::getTable('User')
->createQuery('u')
->where('u.id = ?',$id)->fetchOne();

$newForm = new UserForm($user);
if($request->isXmlHttpRequest())
return $this->renderPartial('form',array($newForm));

my jquery (in the editSuccess.php):
jQuery(document).ready(function(){
var inputfield = jQuery('#provider_user_id');
inputfield.change(function(){
jQuery.ajax({
type: "POST",
url: "updateUserForm",
data: "user_to_change=" + inputfield.val(),
success: function(j){
var obj = jQuery.parseJSON(j);
var name = obj.name;
var ele = jQuery("#user_Details_name");
//ele.val(j.getName());
}
});
})
})


In the ajax-response i always get the following error:
Undefined variable: form in <b>E:\xampp\....\frontend\modules\users\templates\_form.php</b> on line <b>1

Could someone give a hint, what i'm doing wrong??
Hansi
Junior Member
 
Posts: 5
Joined: Sun Feb 05, 2012 12:39 pm

Return to symfony 1.3 and 1.4

Who is online

Users browsing this forum: No registered users and 7 guests