2010-08-03 32 views
3

我一直在想如何使用jQuery BBQ插件。幫助使用帶表格的jQuery BBQ插件

我已經能夠通過從網站複製代碼將它添加到我的網站,但我看到如果我在其中一個選項卡中有表單,我無法成功發佈任何結果。

有沒有人使用過這個插件並習慣了它的功能?我需要幫助確定在哪裏輸入我的php代碼進行表單處理,並讓結果返回到頁面加載的頁面。

回答

3

這裏是我最近如何做到的。這似乎工作得很好。我搞砸了一堆這些不同的jQuery的深層鏈接工具,直到最後我意識到燒烤是最好的。

$("form").live('submit',function(event){ 
    event.preventDefault(); 
    //console.dir(event); 
    var url = $.bbq.getState("url"); 

    $.ajax({ 
     url: url, 
     error: function(XMLHttpRequest, textStatus, errorThrown) { 
      error=true; 
      //alert("communication error"); 
      handler(XMLHttpRequest.responseText,error); 
     }, 
     type: "POST", 
     data: $("form:not(#UserLoginForm)").serialize(), 
     dataType: "json", 
     processData: false, 
     success: function(data, textStatus, XMLHttpRequest) { 
      $('.content').html(data.html); 
      var href = data.address; 
      var url = $.bbq.getState("url"); 
      $.bbq.pushState({ url : href }); 
      //console.dir(data); 
      console.log("loaded new page"); 
      //alert('Load was performed.'); 
      bindFunc();  
     } 
    });