title: POST and Get in the same Ajax request
body: <p>I am using a ajax post in my application like</p>
  
  <pre><code> $.ajax({
       type: "POST",
      url: "http://localhost/FormBuilder/index.php/forms/saveForm/"+user_id,
  
      data: "formname="+formname+"&amp;status="+status,
       success: function(msg){
       // alert( "Data Saved: " + msg);
                  }//success
   });//ajax
  </code></pre>
  
  <p>In the above ajax post i am saving the Form with the user id</p>
  
  <p>Could i able to get the Form id of the Form that i saved in the Ajax request . If so how??</p>
  
  <p>I have tried with Ajax get in a separately.But here i want to mix up both post and get..
  Could i do that..
  EDIT:</p>
  
  <p>COuld i return any value for the Ajax POST method . Since i want to return the Form id of the Form saved..</p>
  
  <p>Edit:</p>
  
  <pre><code>alert("Data Saved: "+msg); gives as
  
   Data Saved: {"forms":[{"id":"41"},{"id":"35"},{"id":"34"},{"id":"33"},{"id":"32"},{"id":"22"},{"id":"3"},{"id":"2"},{"id":"1"}]}
  </code></pre>
  
  <p>THe above is what the value returned i want only th id 41 how should i get it??</p>
  
  <p>EDIT:</p>
  
  <pre><code>     $.ajax({
       type: "POST",
      url: "http://localhost/FormBuilder/index.php/forms/saveForm/"+user_id,
      datatype: 'json',
      data: "formname="+formname+"&amp;status="+status,
       success: function(json){
          alert( "id is : " + json.forms[0].id);
                              }//success
       });//ajax
  </code></pre>
  
  <p>Even i tried it with the above code as suggested, But i am not able to get the alert message..</p>
  
  <p>My controller code is like</p>
  
  <pre><code>     function saveForm()
      {
              //$userId=$this-&gt;Session-&gt;read('userId');
          $this-&gt;data['Form']['name']=$this-&gt;params['form']['formname'];
              $this-&gt;data['Form']['created_by']=$this-&gt;Session-&gt;read('userId');
              $this-&gt;data['Form']['status']=$this-&gt;params['form']['status'];
              $this-&gt;data['Form']['access']="Private";
              $userId=$this-&gt;Form-&gt;saveForms($this-&gt;data);
              $formid = $this-&gt;Form-&gt;find('all', array('fields' =&gt; array('Form.id'),
                                      'order' =&gt; 'Form.id DESC'                                                                           ));
  
  
  
              $this-&gt;set('formid',$formid);
  
      }
  </code></pre>
  
  <p>And my save_form.ctp has</p>
  
  <pre><code>      &lt;?php
       $data=array();
  
        ?&gt;
       &lt;?php foreach ($formid as $r): 
  
  
        array_push($data, array('id' =&gt; $r['Form']['id']));
  
      endforeach; 
  
       echo json_encode(array("forms" =&gt; $data));
  
      ?&gt;
  </code></pre>