Thanks a mix between the button type="button" and the tip about my form beeing submit before the ajax help me figure out what was the problem.

Ryan wrote:
My question has been hijacked with another!  :)

On Dec 6, 4:36 pm, "Jake McGraw" <[EMAIL PROTECTED]> wrote:
  
Perhaps try <button type="button" ...> instead of <button type="submit"
...>.

Haven't tested, but it looks like maybe your form is trying to submit before
the AJAX gets a chance to resolve.

- jake

On Dec 6, 2007 1:53 PM, Marcelo Wolfgang <[EMAIL PROTECTED]> wrote:



    
Hi list
      
Long time lurker, first time poster, so here it goes:
      
I have a simple form that call a $.get, if I have a <input
type="button"> my code works but if I have a <button></button> it
doesn't ... can anyone tell me what I'm doing wrong? here's the code:
      
   <script type="text/_javascript_" src=""></script>
   <script type="text/_javascript_">
   $(document).ready(function(){
       $("#btSubmit").click(function () {
          var id = $("#user_id").val();
          var number2 = $('#number2').attr('value');
          $.get("a_edit.php", { userid: id, number2: number2 },
              function(data){
                 alert("Data Loaded: " + data);
                 $("#edit_response").append(data);
          });
      });
   });
   </script>
      
and the html that works
      
   <form>
       <input type="hidden" name="user_id" id="user_id" value="10" />
       <input type="button" id="btSubmit" value="=" />
   </form>
   <div id="edit_response"></div>
      
and the html that don't work:
      
   <form>
       <input type="hidden" name="user_id" id="user_id" value="10" />
       <button type="submit" id="btSubmit"><img
src="" width="94" height="16" alt="subit
form" /></button>
   </form>
   <div id="edit_response"></div>
      
TIA
Marcelo Wolfgang
      

  

Reply via email to