Angular>> $http and jquery>>$. Ajax comparison

Source: Internet
Author: User

Public agreement

            // contains the information passed in, and the status            of this page $scope. pagestate = {                edittype: $location. Search (). EditType,// value range: Modify, Create                ismodify: ($location. Search (). EditType = = "Modify")                ,= = "Modify")? ' Put ': ' Post ',                ID: $location. Search (). ID,            };

Angular

                //Execution$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) {});

                //Execution$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

                    vartimestamp =NewDate (). GetTime (); vardata =NewFormData (); 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); varOData =json.parse (data);                            Console.log (OData); if(Odata.code = = 200) {console.log (Odata.code); varURL =Odata.data.AssetUrl; varfilename =Odata.data.AssetName; $(". Summernote"). Summernote (' insertimage ', url, filename);//This solution does not conform to the angular style, the insertion of nodes                                //var editor = $.summernote.eventhandler.getmodule ();                                //editor.insertimage ($scope. summernote.editable, $scope. Prefix + '/' + Data.key);                            }                            Else{console.log (odata.msg);                        }; }, Error:function() {Console.log ("Failed:")                        }                    });

Angular>> $http and jquery>>$. Ajax comparison

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.