cakephp - ajax code for Select Box onchange event -



cakephp - ajax code for Select Box onchange event -

i have select box menu(id,name) , have select box category(cid, cname) , must show category based on menu selected setting menuid "url". here code: http://jsfiddle.net/l8su2/738/

echo $this->form->create('subcategorynew'); echo $this->form->input('menu_id', array('empty'=>'--select--','label'=>'menu','type'=>'select','options'=>$menunew, 'div' => false, 'id' => 'prodid', 'onchange' => 'test()', 'class' => 'form-control')); echo "</br>"; echo $this->form->input('category_id', array('type'=>'select','label'=>'category', 'div' => false, 'id' => 'total','options'=>$catnew, 'class' => 'form-control')); echo "</br>";

first, should add together error trigger see happens. ajax based on json , sending html code. have alter info type. finally, easier, can utilize $.get() , $.post() sure way info coming.

error: console.log, datatype : 'html',

it should test. results in developpement console in chrome or firefox

$.post({ url: "<?=$this->webroot?>admin/subcategorynew/add/"+prodid, data: data, error: console.log, success: console.log, datatype: 'html' });

or

$.get({ url: "<?=$this->webroot?>admin/subcategorynew/add/"+prodid, data: data, error: console.log, success: console.log, datatype: 'html' });

to display info want, via jquery

set callback

success: datatoprocess,

create callback

function datatoprocess(data, status){ // select submenu via id // $.html() replace current html info actual tag info sended $("#idsubmenu").html(data); }

ajax cakephp

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -