公共约定
// 包含传递进来的信息,以及此页面的状态 $scope.pageState = { EditType: $location.search().EditType,//取值范围:Modify、 Create IsModify: ($location.search().EditType == "Modify"), method: ($location.search().EditType == "Modify") ? ‘put‘ : ‘post‘, id: $location.search().id, };
Angular
//执行 $http({ method: ‘get‘, url: "/HandlerApi.GetApiJson.tclywork?ApiPath=Test/Get", params: { OrgName: curElement.val() }, headers: { ‘Content-Type‘: ‘application/x-www-form-urlencoded‘ } }) .success(function (data, status, headers, config) { if (data.code == 200) { $scope.CompanyList = data.data; } }) .error(function (data, status, headers, config) { });
//执行 $http({ method: $scope.pageState.method,// ‘get‘, url: "/HandlerApi.GetApiJson.tclywork?ApiPath=Test/Get", params: $scope.modelOrg, headers: { ‘Content-Type‘: ‘application/x-www-form-urlencoded‘ } }) .success(function (data, status, headers, config) { if (data.code == 200) { $scope.modelOrg = data.data; } }) .error(function (data, status, headers, config) { });
jQuery
var timestamp = new Date().getTime(); var data = new FormData(); data.append("file", files); data.append("key", timestamp); // data.append("token", $scope.uptoken); $.ajax({ data: data, type: "POST", url: "/HandlerApi.GetApiJson.Tclywork?ApiPath=Upload/Post&client_id=ba1deb01b25f4620ae04904daefed646", cache: false, contentType: false, processData: false, success: function (data) { console.log("success:"); console.log(data); var odata = JSON.parse(data); console.log(odata); if (odata.code == 200) { console.log(odata.code); var url = odata.data.AssetUrl; var filename = odata.data.AssetName; $(".summernote").summernote(‘insertImage‘, url, filename);//此种解决方案并不符合Angular风格,插入节点 // var editor = $.summernote.eventHandler.getModule(); // editor.insertImage($scope.summernote.editable, $scope.prefix + ‘/‘ + data.key); } else { console.log(odata.msg); }; }, error: function () { console.log("failed:") } });
时间: 2024-10-12 02:25:06