2012-05-02 98 views
0

我想用jQuery和Sugar REST API登錄到SugarCRM。到目前爲止,我沒有運氣。以下是代碼片段:SugarCRM REST API和jquery

  var returnVal = $.ajax(,{ 
       type: "POST", 
       url: "http://127.0.0.1:101/sugarcrm/service/v4/rest.php?method=login", 
       dataType: "json", 
       method: login, 
       success: function(response){ 
        alert("Done it"); 
       }, 
       data: data1, 
       failure: failedAjax 
      }); 

回答

2

試試這個片斷,看看它是否效果更好....

$.ajax({ 
    type: "POST", 
    url: "http://127.0.0.1:101/sugarcrm/service/v4/rest.php", 
    data: { method: "login", input_type: "JSON", response_type: "JSON", rest_data: data1 }, 
    dataType: "json" 
    success: function(result){ 
     if (result.id) { 
      alert("Success! Session ID is " + result.id); 
     } 
     else { 
      alert("Error: " + result.name + " - " + result.description); 
     } 
     } 
    }, 
    failure: failedAjax 
});