【发布时间】:2014-09-05 16:35:31
【问题描述】:
我正在尝试为 Windows 开发一个侧边栏小工具。
除了我对小工具了解不多的问题外,一切都运行良好。 我试过搜索网络,文档很少,而且也不太清楚。
我现在面临的问题是我使用 Ajax 从服务器获取数据。现在我想在弹出窗口中显示返回的数据。 但最大的问题是如何将数据发送到弹出窗口,搜索网络却找不到任何有用的东西。是的,那里有很多示例,但是这些示例中的代码太多,我无法弄清楚发生了什么。
下面是我的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();
}*/
}
我想在弹出菜单打开时即
当System.Gadget.Flyout.show = true; 设置为true 时,数据应发送到弹出窗口。
【问题讨论】:
标签: javascript jquery html windows-desktop-gadgets