Asynchronous data transfer without AJAX

    Hello, in Internet applications, AJAX technology is increasingly used, which allows you to transfer data from the browser to the server and vice versa, without reloading the page. But what if we cannot use AJAX, and we need to get the data.

    A typical example when we cannot use AJAX is to receive data from another domain. Now I will tell you about a method that helps to solve this problem.

    The method is very simple, we create a script tag, and the browser itself loads the data.

    var script = document.createElement ('script');

    script.setAttribute ('type', 'text / javascript');
    script.setAttribute ('language', 'JavaScript');
    script.setAttribute ('src', 'Your url');

    document.

    Well, that’s all, on the server, we can generate the script we need.

    PS To completely fool the browser, you can send header: "Content-Type: text / javascript" on the server, but it works without it.

    Also popular now: