我有一个PhoneGap应用程序,它接受用户提示值并将该参数上传到我的公司服务器。启动一个流程,创建一个图表并将其返回给应用程序。脚本进入console.log()语句,但executeSQL函数不起作用。我将数据库声明在顶部,所以我不确定我错过了什么。我没有收到任何错误,但价值没有传递给
var locationStr;
window.gp_chart = new Geoprocessor("http://ourserver.com/arcgis/rest/services/Three_Week_Chart/GPServer/ThreeWeekChart");
var link = domConstruct.create("a",{
"class": "action",
"id": "chartLink",
"innerHTML": "Three Week Chart", //text that appears in the popup for the link
"href": "javascript: void(0);"
}, query(".actionList", map.infoWindow.domNode)[0]);
on(link, "click", function()
{
// database setup
var db = window.openDatabase("myDB", "", "DB", 100000);
window.navigator.notification.prompt(
"Enter Location Name: ", // message
handleLocationPrompt, // callback
"Add location", //title
["Ok", "Exit"] // button titles
);
// handle user's dialog action
function handleLocationPrompt(results) {
if (results.buttonIndex === 1) {
// Ok
locationStr = results.input1
addLocationToDB(locationStr);
}
}
function addLocationToDB(locationStr){
if (!locationStr) return; // don't add empty string
// run query, pass success callback function as 3rd parameter
console.log(locationStr);
db.transaction(function(tx) {
tx.executeSql("INSERT INTO cat (Name) VALUES (?)", [locationStr], querySuccess);
});
}
var lat,lon = "";
lat = x.toString();
lon = y.toString();
var taskParams = {
"Latitude": lat,
"Longitude": lon,
"Location": locationStr
};
// handle successful db insertion
function querySuccess() {
domAttr.set(dom.byId("chartLink"), "innerHTML", "Generating Chart...");
window.gp_chart.execute(taskParams, gpChartResultAvailable, gpChartFailure);
}
答案 0 :(得分:0)
嗯,这很有效。
var locationStr;
window.gp_chart = new Geoprocessor("http://ourserver.com/arcgis/rest/services/Three_Week_Chart/GPServer/ThreeWeekChart");
var link = domConstruct.create("a",{
"class": "action",
"id": "chartLink",
"innerHTML": "Three Week Chart", //text that appears in the popup for the link
"href": "javascript: void(0);"
}, query(".actionList", map.infoWindow.domNode)[0]);
on(link, "click", function()
{
window.navigator.notification.prompt(
"Enter Location Name: ", // message
handleLocationPrompt, // callback
"Add location", //title
["Ok", "Exit"] // button titles
);
// handle user's dialog action
function handleLocationPrompt(results) {
if (results.buttonIndex === 1) {
// Ok
locationStr = results.input1
var lat,lon = "";
lat = x.toString();
lon = y.toString();
var taskParams = {
"Latitude": lat,
"Longitude": lon,
"Location": locationStr
};
domAttr.set(dom.byId("chartLink"), "innerHTML", "Generating Chart...");
window.gp_chart.execute(taskParams, gpChartResultAvailable, gpChartFailure);
}
}