I tried to use the same solution as you, but it does not work. Ajax is fine when I access it directly from the URL, and I get the impression that the click does nothing. When i use
<fieldset><legend><?php __(' Run 1');?></legend> <div id="formUpdateID"><div id="#error-message"></div> <?php $orders=array_merge($emptyarray,$orders['r1']['Order']); echo $this->Form->create('Order'); echo $this->Form->input('id', array('value'=>$orders['id'],'type' =>'hidden')); echo $this->Form->input('race_id', array('value'=> $orders['race_id'],'type' =>'hidden')); echo $this->Form->input('driver_id', array('value'=>$session->read('Auth.User.driver_id'),'type' =>'hidden')); echo $this->Form->input('run', array('value'=>$run,'type' =>'hidden')); echo $this->Form->input('pm', array('value'=>$orders['pm'],'error'=>$err[$run])); echo $this->Form->input('pr', array('value'=>$orders['pr'],'error'=>$err[$run])); echo $this->Form->input('fuel', array('value'=>$orders['fuel'],'error'=>$err[$run])); echo $this->Form->input('pit', array('value'=>$orders['pit'],'label' => __('Pit on lap '),'error'=>$err[$run])); echo $this->Form->input('tyre_type', array('value'=>$orders['tyre_type'],'error'=>$err[$run])); echo $this->Js->submit('Modify', array( 'url' => array( 'controller' => 'orders', 'action' => 'ajax_edit' ), 'update' => '#error_message' )); echo $this->Form->end(); ?> <?php pr($this->validationErrors); ?> </div></fieldset>
and in control "orders":
function ajax_edit($id=null){ $this->autoRender = false; if($this->RequestHandler->isAjax()) { die(debug('In Ajax')); $this->layout = 'ajax'; debug('didn\'t validate logic'); } echo 'hi'; }
None of the messages are displayed.
I have hard JS / ajax with hard coding that this piece of code does not aim at. I copied the ajax layout in the webroot / view folder.
I see AJAX code displayed in formatted source code
<div class="submit"><input id="submit-1697561504" type="submit" value="Modify" /></div> </form><script type="text/javascript"> //<![CDATA[ $(document).ready(function () {$("#submit-1697561504").bind("click", function (event) {$.ajax({data:$("#submit-1697561504").closest("form").serialize(), dataType:"html", success:function (data, textStatus) {$("#error_message").html(data);}, type:"post", url:"\/Webmastering\/form1C\/frame\/orders\/ajax_edit\/1"}); return false;});}); //]]> </script>
By the way, I'm starting to get bored due to the lack of a document in cakephp and its inefficiency, to realize the task is more difficult than just posting a blog post. So thanks for your help before I start destroying my computer;)