2012-07-07 5 views
0

jquery ajax를 사용하여 server.when에서 값을 가져 오는 방법을 아약스 성공 또는 오류로 가져 왔습니다. 그 값을 반환해야합니다. 수행 방법. 안내하십시오. . 내가 checkNetConnection()를 호출 할 때아약스에서 값을 반환하는 방법

$.ajax({ 
    cache: false, 
    async: true, 
    type: "GET", 
    timeout:6000, 
    dataType: "json", 
    url:url +"log", 
    data: { ContactEmail : $("#username").val()}, 
    contentType: "application/json;charset=utf-8", 
    success: function (result) 
    { 
     //Here I need to return the result and should get in another method 
    }, 
    Error: function (e) 
    { 
     //Here I need to return the result and should get in another method 
    } 
}); 

갱신 예를 에 대한

, 그것은 value.i이

function checkNetConnection() 
{ 
     var netresult=0; 
     var networkState = navigator.network.connection.type; 
     var states = {}; 
     states[Connection.UNKNOWN] = 'Unknown connection'; 
     states[Connection.ETHERNET] = 'Ethernet connection'; 
     states[Connection.WIFI]  = 'WiFi connection'; 
     states[Connection.CELL_2G] = 'Cell 2G connection'; 
     states[Connection.CELL_3G] = 'Cell 3G connection'; 
     states[Connection.CELL_4G] = 'Cell 4G connection'; 
     states[Connection.NONE]  = 'No network connection'; 
     if(states[networkState]=='Ethernet connection'||states[networkState]=='WiFi connection' || states[networkState]=='Cell 2G connection' || states[networkState]=='Cell 3G connection' || states[networkState]=='Cell 4G connection') 
     { 
      netresult=1; 
     } 
     else 
     { 
      netresult=0; 
     } 
     return netresult; 
} 

답변

관련 문제