如果您console.log的代码中有语句,Internet Explorer将抛出JavaScript错误(至少在我们的Intranet用户安装的IE7中).
我在大多数开发测试中使用Firefox主要是因为Firebug提供的功能(我使用了大量的控制台语句)但我还需要在IE中进行测试.
如果我将以下内容添加到我的JavaScript中,则不会抛出错误.
var debugging = false;
if (typeof console == "undefined")
var console = { log: function() {} };
Run Code Online (Sandbox Code Playgroud)
问题是如果调试模式为false,我想触发一个事件.如果我创建一个函数来测试调试是否为false并执行操作(此时只是一个警报)但是当我尝试执行以下操作时,我收到一个IE错误,说明控制台未定义.
var debugging = false; // or true
if (typeof console == "undefined")
var console = { log: function() {consoleMsg()} };
function consoleMsg() {
if(!debugging) {
alert('Console.log event in Production Code');
}
Run Code Online (Sandbox Code Playgroud)
如果有人可以帮我修改我的代码,提供一个更好的方法来帮助我实现我的目标,或者指导我一个资源来教育我自己,我会非常感激.
我在大多数项目和繁重的工作中使用CFEclipse,但有时我发现需要在项目范围之外的页面上快速修复,这在简单的文本编辑器中更容易实现.
我用谷歌搜索但似乎无法找到答案,所以无论是下载链接还是如何构建我自己的链接都会很棒.谢谢.
我创建了一个javascript对象
var spanglist = {
one: q1,
two:q2,
three:q3,
four: q4};
Run Code Online (Sandbox Code Playgroud)
我创建了一个ajax jquery对象来将数据发送到CFC:
$.ajax({
url: 'gridly/components/pay.cfc',
type:"POST",
dataType:' json',
data: {method: "structFromJSobjt",
returnFormat:"json",
jsStruct: spanglist}
});
Run Code Online (Sandbox Code Playgroud)
在我的cfc中,我有以下简单的代码:
<cffunction name="structFromJSobj" access="remote" output="false" >
<cfargument name="jsStruct" required="true" default="" />
<!--- AT this point I would like to work with the data contained in the jsStruct object. I can't access the data regardless of the typeI make the cfargument --->
</cffunction>
Run Code Online (Sandbox Code Playgroud)
一旦有人在数据中,有人可以指导我使用数据.
尝试使用首选的on方法调用,但代码不能使用,但可以使用live方法.
好的,我有一个简单的按钮元素.
<button id="EditVal" name="EditVal" style="btn" value="Edit Debt">Edit Debt </button>
Run Code Online (Sandbox Code Playgroud)
如果我使用live方法,则此代码有效:
$("#EditVal").live("click", function(e){
alert('Edit this Val');
})
Run Code Online (Sandbox Code Playgroud)
但事实并非如此
$("#EditVal").on("click", function(e){
alert('Edit this Val');
})
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我用以下代码调用函数:
var resultz = nsEditor.updateStringCall(debtID, column2Change, value2Change, 4, 10);
Run Code Online (Sandbox Code Playgroud)
正在调用的函数但不返回值
updateStringCall: function(pdebtID, pcolumn2Change, pvalue2Change, pmin, pmax){
try {
var resultz2 = 0;
$.ajax({
type: "POST",
url: "Components/MintLibraries.cfc",
dataType: "json",
cache: false,
data: {
method: 'StringUpdate',
val2Change: pvalue2Change.trim(),
debtID: pdebtID,
column2Change: pcolumn2Change,
greaterThan: pmin,
lesserThan: pmax,
returnFormat: "json"
},
success: function(response) {
resultz2 = 1;
return resultz2;
}, //end done
error: function(jqXHR, textStatus, errorThrown){
resultz2 = 0;
return resultz2;
}); //end ajax call
} catch (e) {
resultz2 = 0;
return …Run Code Online (Sandbox Code Playgroud) 我已经看到大量的教程显示带有flask和flash-wtf的登录表单,但是没有从数据库表值中填充多个选择框的教程.
这就是我想要做的:
简单的注册表格:
名字
姓
地址第一行
地址第2行
市
状态ID(从Id,state的状态库查询填充)
国家/地区ID(从国家/地区库中查询国家/地区,ID)
我们将非常感谢示例代码或指向漫游的链接.
我发现了一个非常有用的正则表达式,用于测试正则表达式示例站点中日期字段的格式和内容
但是当我输入2000年以前的日期时我得到了验证,因为这是一个输入出生日期的字段,你可以看出它为什么会出问题.我确信这是一个简单的修复,但正则表达式威胁我.
$('#txtDOB').blur(function() {
//$('span.error-keyup-5').remove();
var inputVal = $(this).val();
var dateReg = /^[0,1]?\d{1}\/(([0-2]?\d{1})|([3][0,1]{1}))\/(([1]{1}[9]{1}[9]{1}\d{1})|([2-9]{1}\d{3}))$/;
if(!dateReg.test(inputVal)) {
alert('invalid date format: ' + inputVal);
}
Run Code Online (Sandbox Code Playgroud)
我没有和这个解决方案结婚,所以如果你能建议一个更好的方法,请评论.
javascript ×4
jquery ×4
coldfusion ×3
ajax ×1
cfc ×1
cfml ×1
firebug ×1
flask ×1
json ×1
notepad++ ×1
python-2.7 ×1
railo ×1
regex ×1