I am trying to open a SharePoint aspx file in the layouts folder in a dialog box.
This file is designed to be opened in a dialog box so I dont need '?IsDlg=1'
The issue is that the page loads values from POST data. For the examples I will be trying to send the sites title. I have tried multiple methods..
METHOD 1: using 'args' option parameter
If unfamillar here is an msdn like to the options http://msdn.microsoft.com/en-us/library/ff410058(v=office.14).aspx
var options ={
title: 'Sending POST Data',
autoSize:true,
args: { myDocTitle : document.title },
url: 'https://'+window.location.hostname+'/_layouts/targetFile.aspx'
};
SP.UI.ModalDialog.showModalDialog(options);
RESULT : Page Loads, No data. submit page form works
METHOD 2: Pass FormLike Object as argument
var myObj = new Object();
myObj.myDocTitle = document.title;
var options ={
title: 'Sending POST Data',
autoSize:true,
args: myObj,
url: 'https://'+window.location.hostname+'/_layouts/targetFile.aspx'
};
SP.UI.ModalDialog.showModalDialog(options);
RESULT: Page Loads, No Data. sumbit page form works
Method 3: Use jQuery Post show data
function showObj(data){
var ele = document.createElement('div');
ele.innerHTML=data
var options ={
title: 'Sending POST Data',
autoSize:true,
html:ele
};
SP.UI.ModalDialog.showModalDialog(options);
}
jQuery.post('https://'+window.location.hostname+'/_layouts/targetFile.aspx',{ myDocTitle : document.title },function(data){showObj(data);});
RESULT: Page Loads with Data, submitting page form doesnt do anything
METHOD 4: Submit post within dialog
var ele = document.createElement('div');
ele.innerHTML='<form id="myForm" method="post" action="https://'+window.location.hostname+'/_layouts/targetFile.aspx+'" ><input type="hidden" name="myDocTitle" value="'+document.title+'" /></form>"
var options ={
title: 'Sending POST Data',
autoSize:true,
html:ele
};
SP.UI.ModalDialog.showModalDialog(options);
jQuery("#myForm").submit();
RESULT: Redirects whole browser but has data & sumbit form works
I am trying to avoid creating a layout page just for the redirect