in my application i am using Ajax post like

$('#fb_contentarea_col3 #fb_contentarea_col1down2 #saveForm').live("click", function(){


        var formname=$("#formName").val();
                type: "POST",
                 url: "http://localhost/FormBuilder/index.php/forms/saveForm/",
                    async: false,
                    data: "formname="+formname+"&status="+status,
                success: function(msg){
                getformid=msg;//returned FOrm id is saved in the JQuery variable

            $("#fb_contentarea_col1down21 div").each(function() { 
               alert("Form id "+getformid);//alerts me the Form id retrieved 
               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(/<span.*/,'');

                         if($("#label"+id+"> span.req").length > 0)



                                 type: "POST",
                                 url: "http://localhost/FormBuilder/index.php/forms/saveField",
                                     async: false,
                                    data: "sequence_no="+id+"&name="+fname+"&type="+ftype+"&size="+fsize+"&instr="+finstr+"&formid="+getformid+"&required="+checked,

                                success: function(msg){
                                //alert( "Data Saved: " + msg);
            }//for each DIv in mu design page i am saving them as Field

            }//if formname exists

The Form id as returned from the Controller side is saved in the variable getformid correctly, But it is not reflected in the savefield ajax post..And it is saving as 0 only even it alerts as the returned Form id..Please suggest me..

In addition i am giving here the Code inmy Controller for saveForm

function saveForm() {




And my Model saveForms is like

function saveForms($data)//design saveForm

    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;?>

Mmmmmm, "model", view", "controller" .... it sounds like you're using some sort of framework. It would help to know which one?


I am using CakePHP framework

Have a look at your browser's JavaScript Console.

At a quick glance, your javascript appears to have unbalanced () brackets. If I'm right then you will be getting a JavaScript error as the page loads.


I am using Firebug and i didnt find any error like that

As far as I can see, the following lines should be }); , not just } .

}//for each DIv in mu design page i am saving them as Field

Otherwise there are 32 open brackets and only 30 closed.


Sorry i have put as });//div
}); //save form
only in my code in my system while i put the post over here i missed it..

Even that i am getting the wrong answer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.