title: Same Ajax called twice..JQuery
body: <p>i have a question in JQuery..I m using <code>$.ajax()</code> in my code <code>(Function 1)</code>to send the fieldname and the sequence number to the ctrller which gets its data by <code>$_POST['name']</code> and <code>$_POST['sequenceno']</code> and updates the fieldname in the table with sequence no given..And generates the Preview Display Panel with the inserted fields ..
  Now I'm  trying the change the field name again tat is Now when I click on the generated display panel fields, the corresponding settings will open and i will try to change the name of the field now<code>(Function 2)</code></p>
  
  <p>Both <code>Function1</code> and <code>Function2</code> are same ..In the <code>Function1</code> I'm sending the fieldname and the sequence no </p>
  
  <p>In the Funciton 2,i want to send the same fieldname and (but the other value)sequenceno..</p>
  
  <p>But in Function1 (sequenceno is the counter value)
  Whereas in the Function2 (sequenceno is the clicked div id (display Panel))</p>
  
  <p>How can i make use of the same func for both ..Or could i need to use separate funcs..</p>
  
  <p>Even i tried with 2 separate funcs with different urls but not updated correctly</p>
  
  <p>My code is</p>
  
  <pre><code>    //This is what i insert the field initially
  
                $(".TextFieldSettings #fieldTitle").change(function (){
               fieldname=$(".TextFieldSettings #fieldTitle").val();
      $.ajax({
             type: "POST",
             url: "./server",
          data: "name="+fieldname+"&amp;sequenceno="+counter,
  
                  success: function(msg){
                        }//success
             });//ajax
  
       });//change
  
  //After inserting to get the updated values in JSON format
  
       var htm = $.ajax({
         type: "GET",
            url: "./viewforms",
           async: false
         }).responseText;
          var myObject = eval('(' + htm + ')');
  
  
      gettype=myObject.attributes[0]["type"];
     getlabel=myObject.attributes[0]["labels"];
  
      //showing in my DisplayPanel view
  
              $("#labelstr"+counter+"").html(getlabel);
       });//change
  </code></pre>
  
  <p>Now
      When i click the DisplayPanel view</p>
  
  <pre><code>      $("#displayPanel div").live("click", function(){
                               div_id=$(this).attr("id");
  
                                  var htm = $.ajax({
                                    type: "GET",
                                    url: "./getattributes/"+div_id+"",
                                    async: false
                                   }).responseText;
                                  var myObject = eval('(' + htm + ')');
  
  
                                  gettype=myObject.attributes[0]["type"];
                                  getlabel=myObject.attributes[0]["labels"];
                                  getsize=myObject.attributes[0]["size"];
  
      if(gettype=='Text')
       {
      $(".TextFieldSettings").show(function(){
      $(".TextFieldSettings #fieldTitle").val(getlabel);//showing the updated value
                               if(getsize=='100')
                             {
               $("#fieldSize option:contains(Small)").attr("selected",true);
                             }
                               else if(getsize=='200')
                              {
          $("#fieldSize option:contains(Medium)").attr("selected",true);
                           }
                else 
              {
            $("#fieldSize option:contains(Large)").attr("selected",true);
              }
  //Again i m changing the fieldname
  
  
         $(".TextFieldSettings #fieldTitle").change(function (){
        fieldname=$(".TextFieldSettings #fieldTitle").val();
  
  
                                  alert(div_id);
                                          $.ajax({
                                             type: "POST",
                                             url: "./editsettings",
  
  
  
                                                                           data: "name="+fieldname+"&amp;sequenceno="+div_id,
                                             success: function(msg){
  
                                              }//success
                                             });//ajax
  
  
  });//change in text value later*/
  
  
  
                      });//show
                      }//if type = TEXT
  
                  });//displaypanel Div clicked
  </code></pre>
  
  <p>But now if I try to change the fieldname again I'm writing another POST function <code>editsettings</code> but the execution comes inside <code>Func1</code>(changing initially) instead of <code>Func2</code>(changing in the fieldname again)...
  Please anyone get out the answer for this....
  Note:
  <code>$(".TextFieldSettings #fieldTitle").change()</code> is used twice inside my prg ..May be because of this the updation goes wrong</p>