0

我正在尝试使用 jQuery 和 Sugar REST API 登录到 SugarCRM。到目前为止我没有运气。以下是代码片段:

            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
            });
4

1 回答 1

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
});
于 2012-05-03T01:51:17.257 回答