Hi
i am having a Ajax post like
var getformid;
EDIT:
$.ajax({
type: "POST",
url: "http://localhost/FormBuilder/index.php/forms/saveForm/"+user_id,
async: false,
data: "formname="+formname+"&status="+status,
success: function(msg){
alert( "Data Saved: " + msg);
getformid=msg;
}//success
});//ajax */
Now my Formid is saved in the getformid variable , also i alert the getformid outside success function, it shows the ID.But when i tried to use that Formid that getformid variable inside another Ajax like
$("#fb_contentarea_col1down21 div").each(function() {
alert("Form id "+getformid);
var checked="false";
var id=$(this).attr("id");
var fsize=$("#input"+id+"").width();
var ftype=$("#input"+id+"").attr('data-attr');
var finstr=$("#instr"+id+"").text();
var fname=$("#label"+id+"").clone().html().replace(/
Now this getformid value is not reflected inside the Second Ajax to save the Field..
Why so ???
In addition i am giving here the Code inmy Controller for saveForm
function saveForm()
{
$this->data['Form']['name']=$this->params['form']['formname'];
$this->data['Form']['created_by']=$this->Session->read('userId');
$this->data['Form']['status']=$this->params['form']['status'];
$this->data['Form']['access']="Private";
$formId=$this->Form->saveForms($this->data);
$this->set('formId',$formId);
}
And my Model saveForms is like
function saveForms($data)//design saveForm
{
$this->data['Form']['name']=$data['Form']['name'];
$this->data['Form']['created_by']=$data['Form']['created_by'];
$this->data['Form']['status']=$data['Form']['status'];
$this->data['Form']['access']=$data['Form']['access'];
$this->save($this->data);
return $this->id;//returns the saved Form id to the controller
}
And my save_form.ctp in my views folder is like
<?php echo $formId;?>
Please suggest me..