国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

angular.js - How to set up the post request issued by angularjs $resource in detail?
高洛峰
高洛峰 2017-05-15 16:51:40
0
2
764

Angular's service is defined like this (the loginModule is defined in another file, so it is just a reference without writing the second parameter):

angular.module('loginModule').factory('askSecCode',['$resource',
    function askSecCodeFactory($resource){
        return $resource('http://192.168.31.108:8080/retailer/user/auth',{},{crossOrigin:'Anonymous',userName:'QD100',userPass:'1234',checkCode:'1234'});
    }
]);

This is how service is used in the controller:

$scope.loginJump = function(info){
    askSecCode.save(
        {
            userName:info.staffID,
            userPass:info.password,
            checkCode:info.security
        },
        function(){
            console.log('post sent');
        }
    );
    //TODO: ??[?????????????????????][????]
    //TODO: ????????location.assign();
};

The resulting request is as follows:

And the request result is an error

I used jquery to request the same location successfully. The request details are as follows, which is indeed different from the angular request

Help: How can I make requests sent by angularjs be accepted by the backend as CORS cross-domain requests like jquery?

高洛峰
高洛峰

擁有18年軟件開發(fā)和IT教學(xué)經(jīng)驗(yàn)。曾任多家上市公司技術(shù)總監(jiān)、架構(gòu)師、項(xiàng)目經(jīng)理、高級(jí)軟件工程師等職務(wù)。 網(wǎng)絡(luò)人氣名人講師,...

reply all(2)
迷茫

Your problem is due to the inconsistent content-type in the header. The default in jquery is application/x-www-form-urlencoded, while in angular the default is application/json. If you want angular to make the same request as jquery, just change the header of resources

洪濤

Backend settings

header('Access-Control-Allow-Origin:http://192.168.31.172:8000');
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template