Retrieve irev Value in Javascript?

Peter W A Wood peterwawood at gmail.com
Sat Jan 21 09:31:41 EST 2012


Scott

I believe one way around the "same-origin" issue is to return a valid JavaScript script (basically date in JSON format) and dynamically generated a script tag for it. This is known as JSON-P.

Most of the JavaScript frameworks have JSON-P support. JQuery seems to be the most popular ( http://api.jquery.com/jQuery.getJSON/ ). This dojo tutorial may be more help to get you started though ( http://dojotoolkit.org/documentation/tutorials/1.7/jsonp/ ).

Hope this helps.

Peter


On 21 Jan 2012, at 16:50, Scott Rossi wrote:

> Thanks Pierre.
> 
> I came across both of your scripts after posting my message, only to realize
> they won't work for me because my page that is calling the irev script is
> not located on the irev server.  And apparently XMLHttpRequest doesn't work
> across domains.
> 
> Unfortunately I have no control over the server where the my page is stored,
> and no access to any standard server functions.  Is there something else I
> can try to retrieve irev script result remotely?
> 
> Thanks & Regards,
> 
> Scott Rossi
> Creative Director
> Tactile Media, UX Design
> 
> 
> 
> Recently, Pierre Sahores wrote:
> 
>> 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
>> 
>> 
>> 
>> _______________________________________________
>> 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
>> 
> 
> 
> 
> 
> 
> _______________________________________________
> 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





More information about the use-livecode mailing list