jquery - Second $.ajax call stuck the code -


i have ajax+jquery navigation system $.ajax, , i`m trying second call $.ajax send contact form infos, but, when add second $.ajax stop working.

first call -

function loadpage(url) {     url=url.replace('#!','');      $('#loading').css('visibility','visible');      $.ajax({         type: "post",         url: "loader.php",         data: 'page='+url,         datatype: "html",         success: function(msg){              if(parseint(msg)!=0)             {                 $('#conteudo').html(msg);                 $('#loading').css('visibility','hidden');             }         }      });  } 

second call

$("#enviar").click(function() {        var str = $("form").serializearray();      $.ajax({           type: "post",           url: "update.php",           data: str,          success: function(mn) {               if(parseint(mn)!=0)             {              $("#conteudo").html(mn);             $("#enviado").css('visibility','visible');              }      }      return false;  }); 

@edit

very good! first ajax not stucking anymore, second not working expected.

this intended parse $_post values php script , if ok turn div visible..

how i`m doing -

<form name="formcontato" id="form">   <fieldset>     <label>seu nome</label>     <input type="text" name="nome" class="input-block-level">      <label>email</label>     <input type="email" name="email" placeholder="seu@email.com" class="input-block-level">      <div class="form-actions">     <input type="button" name="enviar" value="enviar" id="enviar" class="btn btn-baixar" />       </div>   </fieldset> </form>  

this form.

$("#enviar").click(function () {      var str = $("#form").serialize();      $.ajax({         type: "post",         url: "update.php",         data: str,         success: function (mn) {              alert("ok!");              if (parseint(mn) != 0) {                  $("#conteudo").html(mn);                 $("#enviado").css('visibility', 'visible');              }          }      });      return false;  });  

this js

if($_post) {  $nome = trim($_post['nome']); echo $nome;  } 

this update.php

in posted, second function not close $.ajax() function }); generate parse error , none of code in block available.

try $.ajax() call succesfully closed.

$("#enviar").click(function () {      var str = $("form").serializearray();      $.ajax({         type: "post",         url: "update.php",         data: str,         success: function (mn) {              if (parseint(mn) != 0) {                  $("#conteudo").html(mn);                 $("#enviado").css('visibility', 'visible');              }          }      });      return false;  }); 

fyi, proper , consistent indentation essential spotting these issues.


Comments