Hi. My end goal is to have a button inside or under a codeblock and when pressing the button the code will open in JDoodle. JDoodle writes that you can do it by doing a Form and Post it, see here: Online Compiler and Editor/IDE for Java, C, C++, PHP, Python, Ruby, Perl - Code and Run Online.
What I have tested is to have a button (Buttons plugin) that triggers this code using Templater plugin:
function open_jdoodle () {
let code = `int x = 10;`;
let form = document.createElement("form");
form.action = "https://www.jdoodle.com/api/redirect-to-post/compile-c-sharp-online";
form.method = "post";
form.target = "_blank";
document.body.appendChild(form);
let textarea = document.createElement("textarea");
textarea.name = "initScript";
textarea.append(code);
form.appendChild(textarea);
//NOTE: BROWSER MUST ALLOW POPUPS
form.submit();
console.log(form);
form.remove();
}
module.exports = open_jdoodle;
I have run the same code in a client web app and it works, but what happens now is that JDoodle web page opens and gives the error:
errorCode "INVALID_INPUT"
message "Invalid Input"
errors
0 "Request method 'GET' is not supported"
- First step is to post test code to JDoodle and get that to work.
- Next step is to be able to find the correct codeblock when you press the button and post that code to JDoodle.
Anyone have any ideas how to do it?