---
title: "[Exception... \"Not enough arguments [nsIDOMHTMLSel"
author: "jake0719"
date: "2009-06-18T22:53:43Z"
tags: []
slug: "exception-not-enough-arguments-nsidomhtmlsel"
draft: false
lastmod: "2009-06-18T22:53:43Z"
id: 411214
url: "https://jake007.iteye.com/blog/411214"
---

Exception... "Not enough arguments \[nsIDOMHTMLSelectElement.add]" nsresult: "0x80570001 (NS\_ERROR\_XPC\_NOT\_ENOUGH\_ARGS)" lo+  
关于select添加&lt;option&gt;元素时，出现\[Exception... "Not enough arguments \[nsIDOMHTMLSelectElement.add]" nsresult: "0x80570001 (NS\_ERROR\_XPC\_NOT\_ENOUGH\_ARGS)" lo错误

一般是select对象加option的时候抛出的错误。

这是由于写法document.getElementById(\*\*).add(new Option(\*\*,\*\*));导致的。它不符合W3C dom标准写法。

解决办法：

1\. document.getElementById(\*\*).options.add(new Option(\*\*,\*\*));

2\. document.getElementById(\*\*).appendChild(new Option(\*\*,\*\*));

 

另， 用xmlHttprequest会有浏览器不兼容的问题， 建议用ajax代替。