0
即时通讯尝试开发窗口的侧边栏小工具。发送数据到弹出窗口,侧边栏小工具
一切工作正常,除了从没有太多关于小工具的知识的问题。 我尝试搜索网络,并有很少documentatins,他们也不太清楚。
问题现在我面对我从使用Ajax的服务器获取数据。现在我想在弹出窗口中显示返回的数据。 但是BIG的问题是如何发送数据到弹出窗口,搜索网络,并找不到有用的东西。是的,这里有很多例子,但是这些例子中的代码太多,我无法弄清楚发生了什么。这里下面
是我gadget.html
,主HTML文件 从文件中的一些代码:
function init()
{
System.Gadget.settingsUI = "settings.html";
System.Gadget.onSettingsClosed = settingsClosed;
// Specify the Flyout root.
System.Gadget.Flyout.file = "search.html";
System.Gadget.onDock = DockedChanged; //no longer support in win7
System.Gadget.onUndock = UnDockedChanged; //msdn.microsoft.com/en-us/library/dd370867(VS.85).aspx
this.document.body.style.height = 100;
var evenColorTR = document.getElementById('evenColorTR');
var ColorRows = document.getElementById('data-Tables').getElementsByTagName('tr');
for(var x = 0; x < ColorRows.length; x++) {
ColorRows[x].className = (x % 2 == 0) ? 'even' : 'odd';
}
}
function openSearch()
{
var searchString = document.getElementById("searchBox").value;
var location = "http://localhost/projects/pdoConnection.php";
// var location = "http://www.w3schools.com/ajax/ajax_info.txt";
/* var http = new XMLHttpRequest();
var params = "lorem=ipsum&name=binny";*/
System.Gadget.Flyout.show = true;
var data={
searchFilter:searchString
};
/* $('#testingbaba').text('im inside function');
console.log('I am inside Function');*/
/*
try{
$.ajax({
type:"POST",
url:location,
data:data,
dataType:"json",
cache:false,
success:function(e){
console.log('im the success'+e);
$('#testingbaba').text('im the success'+e);
},
error:function(XMLHttpRequest, textStatus, errorThrown){
console.log('im the error' + e);
$('#testingbaba').text('im the error'+errorThrown);
}
});
}
catch(e) {
$('#testingbaba').text('im the catch'+e);
}
*/
$.post(location, data).done(function(data) {
$('#testingbaba').text(data);
});
/* var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function(e) {
if (xmlhttp.readyState==4) {
$('#testingbaba').text('Hello World');
}
xmlhttp.open("GET",location,true);
xmlhttp.send();
}*/
}
我希望在弹出的是IE打开 时System.Gadget.Flyout.show = true;
设置为true
数据应该被发送到弹出。
如果somedata是主小工具文件中的全局变量,则可以使用System.Gadget.document.parentWindow.somedata更轻松地(并且无磁盘I/O)在弹出脚本中访问它 – mystifeid 2014-10-18 21:54:48