Cross subdomain ajax longpolling

I create script notifications that check the database for changes and then return in a custom javascript popup.

I have successfully completed loading and processing a jquery ajax script and php long polling page. all this worked perfectly apart from the fact that a lengthy request did not allow working with other loaded ajax content. I found that stopping it was to move it to another subdomain. however, this causes problems with js "Policies of the same origin", all possible ways to do this do not seem to work with long connection speeds, and another php proxy option hits the whole point in separate domains.

Does anyone have any ideas how to do this or any help whatsoever.

thank

Oli

+3
source share
2 answers

Another thing you could try is padded json. You can create a dynamic script at some URL that accepts GET parameters, for example sub.domain.com/jsonp.php?var=value, which returns something like:

var response={a:1,b:2}

And you can dynamically load an element <script/>with this url as a source. The variable set in jsonp will be available to other scripts and will not be affected by SOP.

0
source

It is impossible to easily solve this ... the simplest way I have found is the following:

Create an IFrame (yes, I know), this IFrame should load the page coming from the subdomain (sub.example.com/base)

IFrame document.domain .example.com,

  • IFrame
  • IFrame, IFrame ,

, , - , ....

0

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


All Articles