2011-10-24 48 views
5

我一直試圖讓這個跨瀏覽器後語句現在,我收到以下錯誤:AJAX Post請求URL越來越奇怪字符添加

$.ajax({ 
      type: 'POST', 
      url: "http://ourdevtest.com/foo/foo", 
      contentType: "application/x-www-form-urlencoded; charset=utf-8", 
      data: form.serialize(), 
      success:function(result, textStatus, xhr) { 
       form.hide(); 
       console.log('success in preview form'); 
       console.log("result: " + JSON.stringify(result)); 
       console.log("textStatus: " + textStatus); 
       console.log("xhr: " + JSON.stringify(xhr)); 
       app.showThankYou(); 
      }, 
      dataType: 'json' 
      }); 
     }); 
     }, 

返回的控制檯錯誤:POST http://%E2%80%8B/%E2%80%8B/%E2%80%8Buser:%E2%80%[email protected]/%E2%80%8Bfoo/%E2%80%8B1/%E2%80%8Bfoo/%E2%80%8B

它不能加載這個URL,但我不知道如何阻止它添加奇怪的字符。

+0

%E2%80%8B是URL編碼byteform '......奇怪的。 –

回答

0

如果你解碼錯誤響應,你有這個字符串:http://// user: [email protected]/富/ 1/F oo/

我想你應該嘗試直接使用一些字段值,而不是使用form.serialize(),僅用於測試目的。

0

與此

首先是儘量去除

contentType: "application/x-www-form-urlencoded; charset=utf-8", 

形成你的Ajax調用

,並嘗試

success:function(result, textStatus, xhr) { 
     alert("result: " + JSON.stringify(result));    
}