2012-05-02 64 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 
});