I'm not a jsonp fan, it creates a connection between data and presentation, and therefore I have explored this problem before, and well, here is a trick you can use, follow this:
, A "" iframe B.
A B , , :
A sub1.example.com
B sub2.example.com
, , , , , , :
document.domain = "example.com";
B ajax (sub2.example.com), , A, .
B, , , A B , .
, B , .
, , , , .
- , , , , .
-:
in A
==================
document.domain = "example.com";
var child;
function setChild(win) {
childDocument = win;
}
function handleMessage(message) {
do what ever it is you need to
}
in B
==================
make ajax request
document.domain = "example.com";
parent.setChild(this);
function ajaxCallback(message) {
parent.handleMessage(message);
}