

So I tried unsuccessfully to either use XMLHttpRequest to redirect or popup into jdoodle but I cant get to transfer the POST data containing the code. I believe that this doesn't happens with HTML-FORM because it redirects and origin gets to be the same. With XMLHttpRequest to perform the POST call, I get errors on CORS policy.Īccess to XMLHttpRequest at '' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource Now I want this working without the HTML FORM (to keep the HTML simple and clean) and do this in a javascript function call.

The HTML form, works! Either by redirecting or by changing the target to a new tab. Picked jdoodle as starting point, but the idea is to have options. I want to keep the HTML simple and clean.

So I tried my own approach unsuccessfully. I don't know if there is a solution already done. The link should popup a new tab with any online compiler/interpreter and the code of the block. You can always use arrays instead of memory blocks, and array indexes instead of memory addresses.I want a link "Run this in " just below each PRE-CODE block. Note: If your question was more about how to actually write an interpreter in JavaScript, I detail the basics of parts of an interpreter here: It is for C programmers, but the basics hold true in any programming language. have the program run in lldb and then your page sends certain commands to LLDB and returns information. This could be because your JavaScript-based interpreter supports pausing, or your CGI could e.g. Some just have an interpreter or CGI that can remember state between calls, and can then show you intermediate steps. That's what all of these sites essentially boil down to. Then write a web page that calls on that CGI to do the work, usually using AJAXy Javascript things like xmlHttpRequest, or at least a web form. In very simplified terms, there are two ways to achieve a live interpreter/compiler on a web site:įind (or write) a compiler/interpreter for your language that is written in JavascriptĬreate a (native) CGI application and run it on your server that will run a given piece of code through a (native) interpreter/compiler (also on your server) and return the result of the run.
