I have an MVC4 project, and an error that happens usually after the second time of 'SetInterval'. The first time the opening window is fine, but after it I receive an error on this line :
$(w.document.body).html(data.toString());
the error is:
JavaScript runtime error: Permission denied
Here is the code:
<html>
<head>
<meta name="viewport" content="width=device-width" />
<script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
<title>Home</title>
<script type="text/javascript">
alert('1');
$(document).ready(setInterval(function () {
$.ajax({
url: '/api/data/',
data: { pcName: '' },
type: 'GET',
success: function (CLID) {
//
if (CLID != null) {
$.ajax({
data: { line: CLID },
type: 'POST',
datatype: 'html',
url: '/Home/PopPage/',
success: function (data) {
var w = window.open("about:blank", 'PopPage', 'height=300,width=200');
$(w.document.body).html(data.toString());
}
});
}
}
});
}, 2000));
</script>
</head>
<body style=" height: 200px;width: 700px;">
<div>
</div>
</body>
</html>
UPDATE: A Data controller
// GET api/data/5
public string Get(string pcName)
{
string Line="";
SetLogFiles();
Logger.Write("Data");
List<Campaign> CampaignList = new List<Campaign>();
Logger.Write("Before PcName");
// do db logic
try
{
pcName = System.Environment.MachineName;
Logger.Write("PC Name: "+pcName);
Line = DBAccess.GetDataLinesByKey(pcName);
}
catch (Exception ex)
{
Logger.WriteError(ex);
}
return Line;
}