为了账号安全,请及时绑定邮箱和手机立即绑定

从jquery $ .ajax到angular $ http

从jquery $ .ajax到angular $ http

慕侠2389804 2019-11-22 15:44:18
我有一段能很好地跨源工作的jQuery代码:jQuery.ajax({    url: "http://example.appspot.com/rest/app",    type: "POST",    data: JSON.stringify({"foo":"bar"}),    dataType: "json",    contentType: "application/json; charset=utf-8",    success: function (response) {        console.log("success");    },    error: function (response) {        console.log("failed");    }});现在,我试图将其转换为Angular.js代码,但没有成功:$http({    url: "http://example.appspot.com/rest/app",    dataType: "json",    method: "POST",    data: JSON.stringify({"foo":"bar"}),    headers: {        "Content-Type": "application/json; charset=utf-8"    }}).success(function(response){    $scope.response = response;}).error(function(error){    $scope.error = error;});任何帮助表示赞赏。
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 606 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信