is there a way i can send a lot of data to another server asynchronously via javascript without running into cross domain problems?
how is google analytics able to send their encoded data to their servers?
is there a way i can send a lot of data to another server asynchronously via javascript without running into cross domain problems?
how is google analytics able to send their encoded data to their servers?
you can use Ajax to send a lot of data.
Native Javascript:
function NewAjax(){
var xmlhttp=false;
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(E){
xmlhttp = false;
}
}
if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function load_page (url, container){
ajax=NewAjax();
ajax.open("GET", url,true);
ajax.onreadystatechange=function(){
if(ajax.readyState==1){
container.innerHTML = "loading";//<-- Preload
}else if(ajax.readyState==4){
//Page loaded
if(ajax.status==200){
//OK
container.innerHTML = ajax.responseText;
add_action();
}else if(ajax.status==404){
//Page doesn't exist
container.innerHTML = "Erro loading page";
}else{
//Show error
container.innerHTML = "Error:".ajax.status;
}
}
}
ajax.send(null); }
Or
JQuery Ajax:
$.ajax({url: 'ajax/test.html',
success: function(data) {
$('.result').html(data);
alert('Load was performed.');}});