Retrieve irev Value in Javascript?

Pierre Sahores sc at sahores-conseil.com
Sat Jan 21 03:30:32 EST 2012


Scott,

One simple way to go is to add one of the following AJAX functions to your code to let it interact as needed with the irev part of your app :

1.- without using the JQuery framework :

function sendPostData(url, data) {
	// sans jquery ok : deb //
	var xhr_object = null;
	if (window.XMLHttpRequest)		{	xhr_object = new XMLHttpRequest();						}	// Safari, Gecko & W3C
	else if (window.ActiveXObject)	{	xhr_object = new ActiveXObject("Microsoft.XMLHTTP");	}	// Internet Explorer >= 6
	else if (window.ActiveXObject)	{	xhr_object = new ActiveXObject("Msxml2.XMLHTTP");		}	// Internet Explorer < 6
	else { alert("Votre navigateur est trop ancien pour les connexions AJAX..."); return;		}	// AJAX non supporté
  	if (xhr_object)
	{	xhr_object.onreadystatechange=function()
		{	if (xhr_object.readyState == 4)
			{	if (xhr_object.status == 200)
				{ eval(xhr_object.responseText); }
	}	}	}
   	else { return false ; }
    xhr_object.open("POST", url, true); // true = asynchrone
    xhr_object.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr_object.send(data);
    return true;
	// sans jquery ok : fin //
}

2.- in using the JQuery framework :

function postCaltoWSPG(datas) {
	if (datas != '')
	{ 
		$.ajax({
			type: "POST", url: 'http://www.example.com/yourscript.irev', data: 'yourpostitemname=' + datas, dataType: 'text',
			async: 'true', error: function() { alert('Echec du push AJAX.'); }
		});
	}
	else { alert("donnees absentes !"); }
}

Best & Regards,

Le 21 janv. 2012 à 00:04, Scott Rossi a écrit :

> Does anyone have a simple example of using Javascript to pull a value from an irev script?  I've been able to get irev implementations to work using iframes and simple functions, but retrieving a value with Javascript has been elusive.
> 
> Thanks & Regards,
> 
> Scott Rossi
> Creative Director
> Tactile Media, UX Design
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

--
Pierre Sahores
mobile : 06 03 95 77 70
www.widestep.fr : la première solution saas de développement sémantique sans programmation






More information about the use-livecode mailing list