Thenks a lot Mario. I modify my macro and now it's ok. I will try again to implement it but the result it's fine for the moment.
In this example in a tiddler I call the macro with a url <<getDataFromUrl "Eureka" "https://en.wikipedia.org/wiki/Eureka_(word)">> and after I will have a new tiddler loaded asynchronously with tiddlername = "Eureka" and the text of tiddler the returned data from service http://heckyesmarkdown.com/go/ Here is the code that I use: /*\ title: $:/paulin/demo/getDataFromUrl.js type: application/javascript module-type: macro <<getDataFromUrl "tiddlername" "url">> Example to get data from wikipedia: <<getDataFromUrl "Eureka" "https://en.wikipedia.org/wiki/Eureka_(word)">> \*/ (function(){ /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; exports.name = "getDataFromUrl"; exports.params = [ {name: "tiddlername"},{name: "url"}]; /* Run the macro */ exports.run = function(tiddlername,url) { var url = url || "None"; var tiddlername = tiddlername || "None"; //console.log("**** url > "+url); //console.log("**** tiddler > "+tiddlername); //thanks to http://heckyesmarkdown.com/ for the api to get markdown $tw.utils.httpRequest({url: "http://heckyesmarkdown.com/go/?u="+url, callback: function (error,data){ if (error){ console.log("ERROR:"+error); } $tw.wiki.addTiddler({title:tiddlername, text:data, type: "text/x-markdown"}); console.log(data); }}) return "[["+tiddlername+"]]"; }; })(); Il giorno lunedì 8 agosto 2016 11:38:37 UTC+2, PMario ha scritto: > > Hi Paulin, > > Sorry for the late reply. .. TW has a basic callback based ajax utility > built in: see: > https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/utils/dom/http.js > usage can be seen here: > https://github.com/Jermolene/TiddlyWiki5/blob/master/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js > Especially have a look how to use the "options-object"! > > While not ideal, because this workflow is really old, difficult to read, > write and understand, it should have the best browser compatibility > <http://caniuse.com/#feat=xhr2>. .. So it's backwards compatible :/ > > Some time ago I found a good explanation about promises: > http://www.html5rocks.com/en/tutorials/es6/promises/ > and a basic ajax implementation using promises: > https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise#Example_using_XMLHttpRequest > promise browser support: http://caniuse.com/#search=promises > > which will be superseded in the future by window.fetch() > <https://davidwalsh.name/fetch>, which imo hasn't enough browser support > yet. see. http://caniuse.com/#search=fetch > > have fun! > mario > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f1daa393-e807-459e-b22a-296f6034607c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

