2012-08-13 68 views
0

我想在changePage中指定contentType,但它不工作。這是我試過的:在changePage中爲jQuery Mobile指定內容類型?

$.mobile.changePage('/Detail', { 
     type: 'POST', 
     contentType: 'application/json', 
     cache: false, 
     data: JSON.stringify({ 
      item: marker.item 
     }) 
    }); 

這可能嗎?我認爲它會覆蓋常規的jQuery ajax,但似乎並不如此。

回答

0

如果您想覆蓋默認選項,您必須將選項作爲第二個參數傳遞給changePage函數。目前,您在第一個參數後關閉括號,以便您的選項不會作爲參數傳遞給該函數。但是這樣做,它仍然不能按照你的意圖工作,因爲方法中沒有使用contentType選項。請檢查http://jquerymobile.com/test/docs/api/methods.html以瞭解有效選項。

+0

修正了錯字,但仍然無法正常工作。 – TruMan1 2012-08-13 15:15:05

+0

如前所述,「...它仍然不會按照您的預期工作,因爲contentType選項不在$ .mobile.changePage()方法中使用,請檢查http://jquerymobile.com/test/docs/api/methods。有效選項的html。「 – 2012-08-13 15:16:39