[Closed]jQuery入面既AJAX點樣return value?
想進一步簡化jQuery個ajax到只剩read/write
所以將一個jQuery ajax object放在function入面 但個result return唔番出來- function ajax(name, value){
- $.ajax({
- type: "POST",
- url: "ajax.php",
- data: (typeof(value) != 'undefined' ? 'set_' : '' ) + name + "=" + (typeof(value) != 'undefined' ? value : 1 ), //If value exist set it, otherwise get the value
- success: function(msg){
- alert(msg); //OK
- //return msg //not working
- },
- error: function(msg){
- alert(msg); //OK
- alert('Unable to save setting...');
- }
- });
- alert(msg); //undefined
- }
- alert( ajax('setting1') ); //undefined
複製代碼 官網那個都唔work...我唔係好明呢度個callback做緊咩同個variable scope
Error: callback is not a function
http://docs.jquery.com/Frequentl ... _an_AJAX_request.3F
有無高手幫手解解畫
======================================
經過一輸研究後...發現就算整到都唔會做到我想要既結果
個問題無乜意思 所以Close file先
[ 本帖最後由 ~虎~ 於 2009-1-2 02:57 編輯 ] |
|
|