I insert my module, asp.net project, into the "portal", the portal generates an iframe for my URL, I know its crap, but I did not. To avoid a session at the main “portal” end, when the user iterates over my web project, the portal owner told me to start beating from javascript from my application to the portal.
Everyone knows that holding a session this way is unsafe, but there is a "portal" when I have nothing to do. The real problem is that I cannot execute cross-domain requests from my application to the portal, because the same origin policy blocks it, I found a solution using jquery, but this requires a [heartbeat listener] with json.
The official jsonp website is here .
Can someone help me?
there is my script:
function startHeartbeat()
{
var interval = 9513575;
window.setInterval(
function () {
$.ajax({
type: "GET",
cache: false,
async: true,
crossDomain: true,
url: "http://www.theportalurl.com",
dataType: 'JSONP',
complete:function(jqXHR, textStatus){
alert("Complete");
},
success:function(json){
alert("Success");
},
error:function(jqXHR, textStatus, errorThrown){
alert("Error:" + textStatus + ", detail:" + errorThrown);
},
});
}
, interval
);
}
after @rook give me help, I achieve this:
function startHeartbeat(pgn)
{
$("body").append("<img id='heartbeat' style='width:1px; height:1px' name='heartbeat' src='http://www."+Math.random()+".org'/>");
var interval = 350000;
window.setInterval(
function () {
var rnd = Math.random();
var url = "https://www.theportal.com/refreshsession.aspx?pgn="+pgn+"&rndv="+rnd;
$("#heartbeat").attr("src", url);
}
, interval
);
}
source
share