Is there a method in angularJS thats equal to getJSON. [Newbie alert]

后端 未结 6 1322
灰色年华
灰色年华 2021-01-12 15:00

I\'m newbie at javascript, angularJS and JQuery, but I have just started programming a angularJS app where i use JQuery to get a JSON from a webserver like this:

<         


        
6条回答
  •  长发绾君心
    2021-01-12 15:33

    JSONP is used to overcome the cross-domain restriction of the AJAX URL calls.

    With AngularJS (v1.5), you can use this code to send cross domain requests:

    $http.jsonp(baseurl+'?token=assume_jwt_token'+encoding+type + "&callback=JSON_CALLBACK")
    

    The Syntax for AngularJS JSONP request is :

    $http.jsonp(url, [config]);
    

    where url is "string" type representing Relative or absolute URL specifying the destination of the request. The name of the callback should be the string JSON_CALLBACK, and [config] is Optional configuration object.

提交回复
热议问题