1

On a website AAA.com will include a javascript from website BBB.com which has to be non blocking execution script.

The javascript grabbed on BBB.com will extract the meta keywords, the meta title from AAA.com and it'll be sending those data to a particular url to website BBB.com

The BBB.com website will be sending back an url for a video player.

I guess i'll have problem because this is clearly a crossdomain request, which i wanted to solve with an JSON-P request, but the problem is that we can't use jQuery.

How would you achieve that please ?

sf_tristanb
  • 8,725
  • 17
  • 74
  • 118

2 Answers2

1

Neither JSON-P, nor CORS have any slight relevance to jQuery. Which also happens to be library written in Javascript and therefore can never possibly do anything Javascript itself can't.

Also, your scenario doesn't looks like it needs any crossdomain requests at all. Just have on your AAA.com page something like <script src="http://BBB.com/script.js"></script> and it will work, because <script> tag does not impose any origin limitations and never did. Use dynamically created <iframe> and/or <form> tags to asynchronously submit results back to BBB.com as POST or pretty much anything with src (<img>,<script>) to submit them as GET.

Oleg V. Volkov
  • 21,719
  • 4
  • 44
  • 68
1

The first script from BBB.com will have to parse the keywords, serialize them into a URL query and dynamically create a second <script> tag that loads content from BBB.com (this is how you will get around the SOP restriction).

The content from BBB.com would typically be a call to some function inside the first script that knows how to consume the content.

For example, the first script might read like

function showVideoPlayer(parameters) {
   // ...
}

var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://bbb.com/crossdomain?'; // includes serialized meta keywords
// and now append script to e.g. the body so that the request is made

And the content returned would be

showVideoPlayer({param1: "value1", param2: "value2"});
Jon
  • 428,835
  • 81
  • 738
  • 806