问题列表 - 第27590页

IE7 jQuery(文件).ready()问题

我有一个在Firefox中完美运行的页面,但在IE中引发错误.我正在动态加载jQuery(如果它尚未加载),然后在jQuery(document).ready()块中执行一些操作.但是,IE在遇到jQuery(document).ready()块时会抛出可怕的"Object expected"错误.

您可以在此处查看完整页面代码:http://www.pastie.org/977767

IE正在jQuery(文档).ready()中抛出错误.

关于这里发生了什么的任何想法?同样,这在Firefox中运行得非常好.看起来几乎就像IE认为jQuery被加载但是它真的还没有,或者当遇到jQuery(document).ready()块时jQuery仍在加载?

jquery

6
推荐指数
1
解决办法
7179
查看次数

如何使用Perl XML SAX解析器创建XML :: Simple数据结构?

简介:我正在寻找一个快速的XML解析器(很可能是一些标准SAX解析器的包装器),它将生成与XML :: Simple生成的每个记录数据结构100%相同的每个记录数据结构.

细节:

我们有一个庞大的代码基础结构,它依赖于处理记录,并且希望记录是XML :: Simple生成的格式的数据结构,因为它从早期的侏罗纪时代就一直使用XML :: Simple.

一个简单的XML示例是:

<root>
    <rec><f1>v1</f1><f2>v2</f2></rec>
    <rec><f1>v1b</f1><f2>v2b</f2></rec>
    <rec><f1>v1c</f1><f2>v2c</f2></rec>
</root>
Run Code Online (Sandbox Code Playgroud)

例如粗略的代码是:

sub process_record { my ($obj, $record_hash) = @_; # do_stuff }
my $records = XML::Simple->XMLin(@args)->{root};
foreach my $record (@$records) { $obj->process_record($record) };
Run Code Online (Sandbox Code Playgroud)

众所周知,XML :: Simple很简单.更重要的是,由于是一个DOM解析器并且需要在内存中构建/存储100%的数据,因此它非常慢且内存耗尽.因此,它不是解析包含大量小记录的XML文件的最佳工具.

但是,重写整个代码(包含大量"process_record"类似方法)来使用标准SAX解析器似乎是一项不值得资源的大任务,即使以使用XML :: Simple为代价也是如此.

我正在寻找一个现有的模块,它可能基于一个SAX解析器(或任何快速,内存占用很少),可以用来$record根据上面的图片逐个生成hashrefs,可以传递给$obj->process_record($record)100 %与XML :: Simple的hashrefs相同.

我不在乎新模块的界面是什么; 例如,我是否需要调用next_record()或给它一个接受记录的回调代码.

xml perl parsing dom sax

3
推荐指数
2
解决办法
1046
查看次数

单元测试中的ViewResult.ViewName属性为空

在我的单元测试中,当我使用视图的操作名称时,ViewResult.ViewName属性始终为空:

return View(model);
or
return View();
Run Code Online (Sandbox Code Playgroud)

这是设计的吗?

asp.net-mvc

6
推荐指数
1
解决办法
3283
查看次数

使用C#检查字符串是否包含字符串数组中的字符串

我想使用C#来检查字符串值是否包含字符串数组中的单词.例如,

string stringToCheck = "text1text2text3";

string[] stringArray = { "text1", "someothertext", etc... };

if(stringToCheck.contains stringArray) //one of the items?
{

}
Run Code Online (Sandbox Code Playgroud)

如何检查'stringToCheck'的字符串值是否包含数组中的单词?

c# arrays string search

266
推荐指数
7
解决办法
52万
查看次数

html编辑器属性

我在页面上使用了AjaxControlToolkit html编辑器:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor"
TagPrefix="cc1" %>

<cc1:Editor ID="txtjobdesc" runat="server" AutoFocus="False"  />
Run Code Online (Sandbox Code Playgroud)

我将值发送到数据库中 txtjobdesc.Content.Tostring();

但是,如果我在编辑器中只键入一个段落,它将显示相同的描述.如果我使用任何项目符号和突出显示的单词,则会显示项目符号,下方重叠的单词.

如何将其显示为html描述?

请帮帮我..

c# asp.net ajaxcontroltoolkit html-editor

5
推荐指数
1
解决办法
1491
查看次数

编写测试需要帮助

我正在尝试为这个类编写一个名为Receiver的测试:

public void get(People person) {
            if(null != person) {
               LOG.info("Person with ID " + person.getId() + " received");
               processor.process(person);
             }else{
              LOG.info("Person not received abort!");   
              }
        }
Run Code Online (Sandbox Code Playgroud)

这是测试:

@Test
    public void testReceivePerson(){
        context.checking(new Expectations() {{          
            receiver.get(person);
            atLeast(1).of(person).getId();
            will(returnValue(String.class));        
        }});
    }
Run Code Online (Sandbox Code Playgroud)

注意:receiver是Receiver类的实例(真的不是mock),processor是处理person(People类的模拟对象)的Processor类(真实不是mock)的实例.GetId是一个String not int方法,不是错误的.

测试失败:person.getId()的意外调用

我正在使用jMock任何帮助将不胜感激.据我所知,当我称这种get方法正确执行时,我需要嘲笑person.getId(),而且我已经在圈子里徘徊了一段时间,现在任何帮助都会受到赞赏.

java testing junit unit-testing jmock

7
推荐指数
1
解决办法
204
查看次数

使用CookieContainer的WCF Web服务客户端

我开发了一个小型C#表单应用程序,它调用Web服务.一切都运行良好,但我需要保持状态,并且如果我没有记错,我需要使用CookieContainer.

我使用项目的"添加服务引用"菜单创建了服务引用,一切运行良好.但我不知道如何在创建的客户端上添加CookieManager.

我发现一些示例显示样本:

serviceClient.CookieContainer=new CookieContainer()
Run Code Online (Sandbox Code Playgroud)

但这种情况并非如此.我的服务客户端没有这样的属性.我顺便提起Visual Studio 2010 Beta.

先感谢您!

这是生成的ServiceReference(自动创建):

//------------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

// //此代码由工具生成.//运行时版本:4.0.30128.1 // //对此文件的更改可能会导致错误的行为,如果//重新生成代码,则会丢失.// // ---------------------------------------------- --------------------------------

namespace WSClient.SecurityServiceReference {

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://max/", ConfigurationName="SecurityServiceReference.SecurityService")]
public interface SecurityService {

    // CODEGEN: Generating message contract since element name return from namespace  is not marked nillable
    [System.ServiceModel.OperationContractAttribute(Action="http://max/SecurityService/nextValRequest", ReplyAction="http://max/SecurityService/nextValResponse")]
    [System.ServiceModel.TransactionFlowAttribute(System.ServiceModel.TransactionFlowOption.Allowed)]
    WSClient.SecurityServiceReference.nextValResponse nextVal(WSClient.SecurityServiceReference.nextValRequest request);

    // CODEGEN: Generating message contract since element name return from namespace  is not marked nillable
    [System.ServiceModel.OperationContractAttribute(Action="http://max/SecurityService/reportSessionIDRequest", ReplyAction="http://max/SecurityService/reportSessionIDResponse")]
    [System.ServiceModel.TransactionFlowAttribute(System.ServiceModel.TransactionFlowOption.Allowed)]
    WSClient.SecurityServiceReference.reportSessionIDResponse reportSessionID(WSClient.SecurityServiceReference.reportSessionIDRequest request);
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial …
Run Code Online (Sandbox Code Playgroud)

c# cookies wcf web-services cookiecontainer

6
推荐指数
2
解决办法
1万
查看次数

使Eclipse使用src/test/resources而不是src/main/resources

我正在Eclipse中编写一个小的Maven应用程序.我将一些属性文件和我的应用程序上下文存储在目录src/main/resources中.

我现在想让Eclipse在目录src/test/resources中使用属性.因此,当我在Eclipse中运行和调试程序时,应该使用这些测试属性.

你知道我怎么能做到这一点吗?

java eclipse resources maven-2 properties

8
推荐指数
2
解决办法
2万
查看次数

在C++中将文件内容读入字符串

可能重复:
在c ++中将文件粘贴到std :: string的最佳方法是什么?

在像Perl这样的脚本语言中,可以一次将文件读入变量.

    open(FILEHANDLE,$file);
    $content=<FILEHANDLE>;
Run Code Online (Sandbox Code Playgroud)

在C++中最有效的方法是什么?

c++ string file-io

76
推荐指数
4
解决办法
17万
查看次数

Strophe.addHandler只从响应中读取第一个节点是否正确?

我开始学习strophe库使用,当我使用addHandler解析响应时,它似乎只读取xml响应的第一个节点,所以当我收到像这样的xml时:

<body xmlns='http://jabber.org/protocol/httpbind'>
 <presence xmlns='jabber:client' from='test2@localhost' to='test2@localhost' type='avaliable' id='5593:sendIQ'>
  <status/>
 </presence>
 <presence xmlns='jabber:client' from='test@localhost' to='test2@localhost' xml:lang='en'>
  <status />     
 </presence>
 <iq xmlns='jabber:client' from='test2@localhost' to='test2@localhost' type='result'>
  <query xmlns='jabber:iq:roster'>
   <item subscription='both' name='test' jid='test@localhost'>
    <group>test group</group>
   </item>
  </query>
 </iq>
</body>
Run Code Online (Sandbox Code Playgroud)

使用处理程序testHandler就是这样的:

connection.addHandler(testHandler,null,"presence");
function testHandler(stanza){
  console.log(stanza);
}
Run Code Online (Sandbox Code Playgroud)

它只记录:

<presence xmlns='jabber:client' from='test2@localhost' to='test2@localhost' type='avaliable' id='5593:sendIQ'>
 <status/>
</presence>
Run Code Online (Sandbox Code Playgroud)

我错过了什么?这是一种正确的行为吗?我应该添加更多处理程序来获取其他节吗?谢谢你提前

javascript xmpp strophe

5
推荐指数
1
解决办法
5670
查看次数