Hi,

I am new to JQuery and Ajax

I am trying to use the value returned from the Ajax call to the
another Ajax call..
like
        <script type="text/javascript">
          $(document).ready(function(){
              $.ajax({
         type: "POST",
         url: "http://localhost/FormBuilder/index.php/forms/
saveForm/",
               async: false,
                 data: "formname="+formname+"&status="+status,
                 success: function(msg){
                 //alert( "Data Saved: " +
msg);

                            getformid=msg;
                            }//success
                 });//ajax

      $("#fb_contentarea_col1down21 div").each(function() {
       alert("Form id "+getformid);//alerts me the Formid returned
from the Cakephp controller side
                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)
                                                {

                                                 checked="true";

                                                }


                        $.ajax({
                        type: "POST",
                         async: false,
                         url: "http://localhost/FormBuilder/index.php/
forms/saveField",

                             data: "sequence_no="+id+"&name="+fname
+"&type="+ftype+"&size="+fsize+"&instr="+finstr+"&formid="+getformid
+"&required="+checked,
                              success: function(msg){
                        //alert( "Data Saved: " + msg);
                        }//success
                 });//ajax
                });//DIV

        });
       </script>

The First Ajax call returns the Formid and even alerts it correctly in
the Div ,But the returned value in getformid is not reflected in the
second ajax call . Please sugggest me..

Reply via email to