问题列表 - 第31568页

XMLHttpRequest对<input type ="button">与<button>的不同行为

请考虑以下代码:

的index.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <script type="text/javascript" src="script.js"></script>
    </head>

    <body>
        <form>
            <button id="getInfoButton1"></button>
            <input type="button" id="getInfoButton2"></input>
        </form>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

随附JavaScript文件:

的script.js

window.onload = initAll;
var req;

function initAll()
{
    document.getElementById("getInfoButton1").onclick = getInfo;
    document.getElementById("getInfoButton2").onclick = getInfo;
}

function getInfo()
{
    req = new XMLHttpRequest();
    var URL = "index.html";
    req.open("GET", URL, true);
    req.onreadystatechange = whatsTheStatus;
    req.send(null);
}

function whatsTheStatus()
{
    if (req.readyState != 4) { return; }
    alert(req.status);
}
Run Code Online (Sandbox Code Playgroud)

(我已经减少了很多代码,但这个例子仍然突出了错误)

问题是这样:当你加载它,并单击两个按钮时,第一个将显示状态0,而第二个显示状态为200.

当然,我期望两者都显示 …

html javascript xmlhttprequest readystate

3
推荐指数
1
解决办法
1533
查看次数

在一个解决方案中调试托管c#代码和非托管c ++代码

我有一个解决方案,其中包含一个非托管c ++ dll项目,以及一个使用PInvoke调用dll的ac#托管项目.是否可以调试托管代码和非托管代码,以便我看到该内部"内部"发生了什么?

debugging visual-studio

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

如何使用bash冲洗管道

我有一个脚本写入命名管道,另一个脚本从管道读取.有时,在启动脚本时,我注意到管道的内容存在于上一次运行的脚本中.有没有办法在脚本开头清除管道?

bash named-pipes

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

在WPF应用程序中使用Xbox 360控制器

我目前正在尝试在我的WPF应用程序中使用我的Xbox 360控制器,但所有在线教程都指的是在游戏环境中使用XNA.我只是想知道是否有一个很容易让我的应用程序检测我的Xbox 360控制器和任何可能来自它的移动/按钮.我目前的设置是visual studio 2010,.NET 4.0,WPf,C#,我有用于PC的xbox 360无线适配器.谢谢!

c# wpf xbox360

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

AutoMapper和继承 - 如何映射?

有这种情况:

public class Base {  public string Name; }

public Class ClassA :Base {  public int32 Number;  }

public Class ClassB :Base { public string Description;}

public Class DTO {
  public string Name;
  public int32 Number;
  public string Description;
}
Run Code Online (Sandbox Code Playgroud)

我的IList<Base> 地图是:

AutoMapper.Mapper.CreateMap<IList<Base>, IList<DTO>>()
   .ForMember(dest => dest.Number, opt => opt.Ignore())
   .ForMember(dest => dest.Description, opt => opt.Ignore());

AutoMapper.Mapper.CreateMap<ClassA, DTo>()
   .ForMember(dest => dest.Description, opt => opt.Ignore());

AutoMapper.Mapper.CreateMap<ClassB, DTO>()
   .ForMember(dest => dest.Number, opt => opt.Ignore())

Mapper.AssertConfigurationIsValid(); //Is OK!
Run Code Online (Sandbox Code Playgroud)

但是当我这样做时,不会映射ClassA或ClassB中的属性:

IList<DTO>= AutoMapper.Mapper.Map<IList<Base>,IList<DTO>>(baseList);
Run Code Online (Sandbox Code Playgroud)

如何映射在 …

c# inheritance automapper

38
推荐指数
3
解决办法
3万
查看次数

fgetpos/fsetpos和ftell/fseek有什么区别

What's the difference between using the functions fgetpos() and fsetpos() and using the functions ftell() and fseek() to get and set a position in a file?

What are fgetpos() and fsetpos() good for? Why would they be used instead of ftell() and fseek()?

c c-standard-library

29
推荐指数
3
解决办法
1万
查看次数

How to catch UnsatisifiedLinkError when using NDK-built library in an Android app?

I have an Android project that contains a class that uses JNI to pull a value from a C function. The C function was built into a library using NDK. The value returned from the C function is in turn used to initialize a variable inside a class when its first loaded. This works fine. However, I also want it to work when the library is missing by providing a default value. So Im using something like this:

static native …
Run Code Online (Sandbox Code Playgroud)

java-native-interface linker android android-ndk

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

如何读取SD卡ID号?

如何以编程方式读取SD卡的CID寄存器,其中包含序列号和其他信息?我可以通过Android Java或Native代码来实现吗?

埃里克,提前谢谢

c++ windows mfc android

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

在Rails中使用MongoMapper的回形针3

我正在尝试在我的第一个rails应用程序中实现Paperclip,我碰巧使用rails 3和mongodb与mongomapper.

我按照本指南将所有事情放在一起工作

正如博客文章所暗示的那样,我将paperclip放入config/initializers目录,我安装了gem,gem在gemfile中(rails 3右边),我运行了捆绑器.

在我的用户类中,我添加了

require 'paperclip'

当我加载应用程序时,我收到以下错误,

undefined method 'has_attached_file' for User:Class

回形针文件如下所示

module Paperclip
  module ClassMethods
    def has_attached_file name, options = {}
      include InstanceMethods

      write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil?
      attachment_definitions[name] = {:validations => []}.merge(options)

      after_save :save_attached_files
      before_destroy :destroy_attached_files

      define_callbacks :before_post_process, :after_post_process
      define_callbacks :"before_#{name}_post_process", :"after_#{name}_post_process"

      define_method name do |*args|
        a = attachment_for(name)
        (args.length > 0) ? a.to_s(args.first) : a
      end

      define_method "#{name}=" do |file|
        attachment_for(name).assign(file)
      end

      define_method "#{name}?" do
        attachment_for(name).file?
      end

      validates_each name, :logic => lambda {
        attachment …

ruby-on-rails paperclip mongomapper

3
推荐指数
1
解决办法
2772
查看次数

在自定义控件中处理JavaScript的最佳方法是什么?

在ASP.Net中,我有一些自定义控件.我利用了jQuery也帮助了它.好吧,我现在遇到的一个问题(显而易见的,但"坏"的解决方法)是,对于每个用户控件,我需要从内部执行一些代码pageLoad($(document).ready不适用于更新面板).

那么现在我的问题.我需要有两个自定义控件附加到pageLoad事件.

这样做的最佳方式是什么?

我不能这样做

old_pageLoad=pageLoad
pageLoad=function(){... old_pageLoad();}
Run Code Online (Sandbox Code Playgroud)

因为这些自定义控件可以在页面上多次使用,并且脚本需要为控件的每个单个实例运行,如果我在页面上有3个不同的自定义控件,该怎么办?

我提出的唯一方法是这样的东西,似乎超级hackish:

old_pageLoad_<%= MyStaticClass.GetUniqueID() %>=pageLoad;
pageLoad=function(){... old_pageLoad_<%= MyStaticClass.GetUniqueID() %>();}
Run Code Online (Sandbox Code Playgroud)

有没有更好的方法来处理这样的功能冲突?

我也看过这篇MSDN文章,但它的建议看起来比我目前所做的更糟糕.

javascript asp.net webforms custom-controls

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