[英]Call Function with param
I created these two functions that call each other but I can not see why I can not call the function ioFunction(). 我创建了这两个相互调用的函数,但是我看不到为什么不能调用ioFunction()函数。 what can I be doing wrong?
我做错了什么?
This way I get to call the function: 这样我就可以调用该函数:
$("[name=flip-4]").change(function() {
var b = $("#flip-2").val();
var c = $("#flip-3").val();
var d = $("#flip-4").val();
if (b == "on" || c == "on" && d == "off") {
var message = 'the roof cant be close when some setups is on.';
dialogFunction(message);
$("#flip-4").val("on");
} else {
var message = 'the roof will be ' + d + ': ' + output + '.';
var flip = 'flip4';
ioFunction(flip,d,message);
}
});
function dialogFunction(param) {
var html = '<div data-role="dialog" id="page2" data-mini="true" data-close-btn="right">';
html += '<div data-role="header"><h1 style="text-align:left; margin-left:10px;">Atention</h1></div>';
html += ' <div role="main" class="ui-content">';
html += ' <legend>' + param +'</legend> ';
html += ' </div>';
html += ' </div>';
$('#page2').remove();
$('body').append(html);
$('#page2').enhanceWithin();
$.mobile.changePage("#page2");
}
function ioFunction(parama,paramb,paramc) {
$.ajax({
url: 'io.php?'+ parama + '=' + paramb,
dataType: 'text',
success: function(output){
var output = $.trim(output);
if (output == "success") {
dialogFunction(paramc);
} else {
dialogFunction('ERROR: ' + output);
}
}
});
}
I think the problem lies in your if
statement: 我认为问题出在您的
if
语句中:
if (b == "on" || c == "on" && d == "off") {
Do you mean: 你的意思是:
if ((b == "on" || c == "on") && d == "off") {
or 要么
if (b == "on" || (c == "on" && d == "off")) {
? ? Think about putting parentheses around your conditions to make it more explicit.
考虑在条件周围加上括号以使其更明确。
I'm willing to bet that if you put a breakpoint / console.log
or something inside the else
, you would never reach it. 我愿意打赌,如果您将一个断点/
console.log
或其他内容放入else
,您将永远无法到达它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.