我试图创建一个简单的函数,在调用时将返回正确的字符串:
function getState(abbr){
if (abbr=="WY")
{
return "Wyoming";
}
}
Run Code Online (Sandbox Code Playgroud)
然后调用是这样的:
var stateName = getState("WY");
Run Code Online (Sandbox Code Playgroud)
然而,返回的所有内容是:0
对不起,如果我错过了一些明显的事
更新 - 我的原始概率是因为"&"这里是我正在处理的真实代码:
function getState(abbr){
var url = "states.asp"
var state = "";
$.get(url, function(data) {
var i = 0;
$.each($('state',data),function(index, el) {
if (abbr == ($(this).attr("abbr"))){
//alert($(this).attr("abbr"));
state = $(this).text();
}//if (abbr == $(this).attr("abbr")){
});//$.each($('state',data),function(index, el) {
}).success(function() {
alert("x" + state);
return state;
}); //.success(function() {
//$.get(url, function(data) {
alert("y" + state);
return state;
}
Run Code Online (Sandbox Code Playgroud)
我的电话结果是"未定义":
alert(getState("WY"));
Run Code Online (Sandbox Code Playgroud)
警报("x"+状态)有效.
更新#2 ---这里是states.asp生成的所有内容(现在)...稍后它将返回公司等:
<?xml …
Run Code Online (Sandbox Code Playgroud) 我试过在谷歌上搜索答案,但我只是在兜圈子……如果我清除了 rect(使用 clearRect),那么图像不会重绘。但是,如果我不清除图像只是堆叠。我希望它清除当前图像,然后用新图像绘制。我错过了什么?它与图像 Load 有关系吗?对不起,如果这是一个重复的问题,我找不到确切的答案 - 我尝试了其他人的建议,但结果很差。
function clear() {
var canvasTemp = document.getElementById(imgSection);
var ctxTemp = canvasTemp.getContext("2d");
ctxTemp.clearRect(0, 0, 500, 500);
}
function fillColorOrPattern(imgSection,currentcolor){
if ((oldcolor !== currentcolor) || (oldxImgToBeFilled !== xImgToBeFilled)){
clear();
}
imgFill.onload = function () {
imgToBeFilled.onload = function () {
if ((oldcolor !== currentcolor) || (oldxImgToBeFilled !== xImgToBeFilled)){
fill(imgSection,currentcolor)
}
};
imgToBeFilled.src = xImgToBeFilled;
}
imgFill.src = xImgFill;
}
function fill(imgSection,currentcolor){
canvas = document.getElementById(imgSection);
ctx = canvas.getContext("2d");
ctx.drawImage(imgToBeFilled, 0, 0);
ctx.globalCompositeOperation = "source-atop";
console.log(isItColorOrPattern); …
Run Code Online (Sandbox Code Playgroud) 我试图首先打印出来自"GermanDB"数据库的结果,同时还显示波士顿DB中不属于德国数据库的所有内容.这可以在一个查询中完成吗?
我的查询(粗体部分功能但不按我想要的方式排序)
select * from (
SELECT DISTINCT a.ProductRef
FROM GERMANDB.dbo.LOCATIONS AS a INNER JOIN GERMANDB.dbo.ITEMS AS b ON a.ProductRef = b.ProductRef
WHERE b.ACTIVE=1
) ta
UNION select * from
SELECT DISTINCT c.ProductRef
FROM BOSTONDB.dbo.LOCATIONS AS c INNER JOIN BOSTONDB.dbo.ITEMS AS d ON c.ProductRef = d.ProductRef
WHERE c.ACTIVE=1 (c.ProductRef NOT IN
(SELECT ProductRef FROM GERMANDB.dbo.ITEMS where ACTIVE=1))
) tb
order by ta.ProductRef** , tb.productRef
Run Code Online (Sandbox Code Playgroud) javascript ×2
asp-classic ×1
canvas ×1
html5-canvas ×1
return ×1
sql ×1
sql-server ×1
string ×1
t-sql ×1
union ×1