HTML HTML internetworking using AngularJS

We are working on a java project in which the backend is java + spring and the front is angular 2 + HTML.

I want to parse the html syntax, but we don’t have permission to access external links on the server side, since we have some security problems for external domains , so we need to get the contents of the DOM of the link on the client side using jquery.

I tried these:

var url = "http://xyz.aspx";

$http({
    method: 'JSONP',
    url: url,
    params: {
        format: 'jsonp',
        json_callback: 'JSON_CALLBACK'
    }
}).
success(function(response) {
    $scope.test = response;
}).
error(function(status) {
    //your code when fails
});

The external link I need to parse contains many links href. I also need to parse the content of these links.

Tried the above code:

getting console error - Inactive SyntaxError: Unexpected token <on Page xyz.aspx

?

+4
2

1)

- SyntaxError: < xyz.aspx

, JavaScript. , JavaScript. , . JSONP JavaScript-, . , JSONP:

jsonCallback(
    {
        sites: [
            {
                siteName: "Test"
            }
        ]
    }
);

2)

JSON, GET CORS.

$http({
    method: 'GET',
    url: "http://xyz.aspx",
}).success(function(response) {
    $scope.test = response.data;
}).error(function(status) {
    //your code when fails
});

3)

CORS , PROXY. , CORS Proxy https://crossorigin.me/. , -, . , . .

0

. ng. $http. URL- , ,

 json_callback: 'JSON_CALLBACK'

.

$http({
    method: 'jsonp',
    url: 'http://xyz.aspx?callback=JSON_CALLBACK',
    params: { name: 'xyz' }
}).success(function(data, status , header, config) {
    console.log('success');
}).error(function(data, status , header, config) {
    console.log('error');
});
-2

Source: https://habr.com/ru/post/1671969/


All Articles