2012-04-12 77 views
1

我使用$.post()發送一個json到我的cfc,它更新了一些記錄。我沒有將json返回到調用頁面,我只是返回了我在cfc中設置的變量的內容。根據該變量的值,更新是/不成功的。我似乎無法得到變量的內容。我剛開始使用jQuery,所以我認爲我做對了,但顯然不是。

jQuery的:

$("#edit_button").click(function(){ 
    if(theArray.length > 0){ 
     theJson = JSON.stingify(theArray); 
     $.post("cfcs/fund_profile.cfc",{ 
      method:"updateProfile", 
      data:theJson, 
      dataType:"text" 
      success:function(response){alert(response);} 
     }); 
    } 
}); 

我沒有要發佈整個CFC,只是重要組成部分。

我只是返回一個字符串。

+0

FYI你不發送JSON到CFC,要發送的字符串。 – 2012-04-12 13:31:33

回答

2

您錯誤地使用了$.post。這看起來像是$.ajax$.post的混搭。您的電話應該像這樣:

$.post("cfcs/fund_profile.cfc",{ method: "updateProfile", data: theJson}, 
    function(response) { 
     alert(response); 
    }, 
"text"); 

文檔:http://api.jquery.com/jQuery.post/

+0

@ karmin79這是個伎倆。我一直在尋找jquery api的參考,並且我有一種感覺,我做錯了什麼,但我無法破譯它。謝謝。 – 2012-04-12 13:39:18