调用JS函数
alertStatement()
Run Code Online (Sandbox Code Playgroud)
功能定义
function alertStatement(link) {
if (link) {
alert('A');
}
if (link!=null) {
alert('B');
}
}
Run Code Online (Sandbox Code Playgroud)
这两个语句在带有Tomcat的Windows Env中都能正常工作,但它们都没有在生产中执行(Linux服务器).有没有其他方法来比较变量使其工作?
我使用以下javascript代码工作.
function alertStatement(link) {
if (link!==undefined){
alert('A');
}
}
Run Code Online (Sandbox Code Playgroud)
所以最后undefined对我有用,由于某种原因,null比较不起作用
function showDialog(link) {
$('#dialog .newsletter-join').click(function() {
email = $.trim($(this).parent().find('.email').val());
if (email != "Email Address" && email.length > 5) {
$.ajax({
url: '/newsletter/join',
data: {
'email': email,
'pid': $('#dialog .pid').html().trim()
}
});
return true;
}
return false;
});
}
Run Code Online (Sandbox Code Playgroud)
这段代码在FF和chrome中正确执行,在调试模式下执行时运行完美,否则它不会返回任何内容.
执行时,它显示警报框,其中没有任何内容.我在控制台中的XMLHttp响应中也没有看到任何内容.我尝试了一些其他的改变:
cache:false // It just exeutes for the first time
datatype:html
Run Code Online (Sandbox Code Playgroud)
你能告诉我如何追踪这个问题吗?
更新的代码:
我使用以下脚本调用代码
$(document).ready(function() {
// $(window).load(function () {
showDialog();
return true;
//});
});
function showDialog(link) {
$('#dialog .newsletter-join').click(function() {
email = $.trim($(this).parent().find('.email').val());
if (email != "Email Address" && email.length …Run Code Online (Sandbox Code Playgroud) 我正在进行Junit测试,我需要将Easymock和Class对象一起工作来测试.
以下是我的代码段
@Before
public void setUp() {
request=EasyMock.createMock(SlingHttpServletRequest.class);
response=EasyMock.createMock(SlingHttpServletResponse.class);
}
@Test
public void testImage() {
RequestContext ctx = new RequestContext();
// RequestContext and RequestContext Util are both classes defined in Project
expect(RequestContextUtil.setupContext(request,response)).andReturn(ctx);
// This line is throwing an error , so I am not able to add replay or verify method
}
Run Code Online (Sandbox Code Playgroud)
我试着看一个例子,我可以一起使用Easy mock和Class对象,我找不到适合我的情况.任何人都能指出我的一个例子吗?