I am rendering an Iframe within a greasemonkey script, which renders a webpage from my back-end webservice. At the minute I can make a GET request and everything works fine but going forward my URL will be enormous if I want to pass more content to my back-end.
Looking at How do you post to an iframe? I am able to create a form which posts information to my back-end, which then parses the post and dumps it within the IFrame.
What I am looking to do is upon page load make a post request with greasemonkey to my webservice and then render the information within the IFrame without any input from the user.
Below is what I have got so far:
$(document).ready(function() {
/*Get Account ID */
var accountID = getAccountId();
var requestUrl = getUrl();
var subject= getSubject();
/* Find the main container */
var mainContainer = document.getElementById('container');
mainContainer.style.width = '78%';
var divContainer = document.createElement('div');
divContainer.id = "div-Decorator";
/* Post data */
var form = document.createElement('form');
form.action = apiUrl;
form.method = "post";
form.target = "resource-Decorator";
var formInput = document.createElement('input');
formInput.type = "text";
formInput.name = "AccountID"
formInput.value = accountID;
var formInput1 = document.createElement('input');
formInput1.type = "text";
formInput1.name = "Topic"
formInput1.value = caseSubject;
var formInputSubmit = document.createElement('input');
formInputSubmit.type = "submit";
formInputSubmit.value = "post";
var iframe = document.createElement('iframe');
iframe.id = "resource-Decorator";
iframe.name = "resource-Decorator";
iframe.src = requestUrl;
iframe.scrolling = "auto";
divContainer.appendChild(form);
form.appendChild(formInput);
form.appendChild(formInput1);
form.appendChild(formInputSubmit);
divContainer.appendChild(iframe);
document.body.appendChild(divContainer);
});