"Unknown runtime error" occurs when setting innerhtml in Javascript-I also met

Source: Internet
Author: User

The following solutions are available with the help of Google:

In Ajax, the interface is often changed through innerhtml, Which is simpler than Dom.
For example:
Element. innerhtml ="Something"
However, in IE, "unknown runtime error" may sometimes occur, but not in Firefox.
This is mainly because when ie writes innerhtml, it will check whether the element meets the requirements of the HTML object container in the content, for example, if you add the included HTML code to a P file, this will cause an error. So if you find these errors occur, try to do two things:

1. Check whether the HTML code you try to add to innerhtml contains broken HTML tags, such as the HTML code that is not surrounded.

.
2. Change your container to the "inclusive" labels, such

,

Note that,

Add the correct format to the tag
Labels may have errors, so avoid using these labels as containers and use them if necessary.
As a container, you need to set up a table.

 

The problem I encountered was that the [element was not closed due to broken HTML tags, for example, test].

Reference address

I looked at it in this way and found that this was not the case. No way, maybe my eyes are not very good and I have not found out. What is the data returned by Ajax? So I used jquery's $ ("# namelist"). Text

Output the returned content. I didn't expect the text content except the content returned by response. Write.

My code is as follows:

Function addrss () {createxml (); XMLHTTP. onreadystatechange = statedo; document. getelementbyid ('namelist'). value = "loading ...... "; Var rssname = document. getelementbyid ('txtrssname '). value; var rssurl = document. getelementbyid ('txtrssurl '). value; XMLHTTP. open ("get", "addrssnamepage. aspx? Name = "+ escape (rssname) +" & url = "+ escape (rssurl), true); XMLHTTP. Send (null );}
 
AddRssNamePage.aspx
Rssmanager. addrss (rssname, rssurl); response. Write ("RSS added ...... ");

I used XMLHTTP. open () to access this page. addrssnamepage. aspx is a Web page,
So after response, all the other items will be back.
The result is "RSS is successfully added ...... "
 
Therefore, when using innerhtml in IE, an unknown runtime error occurs. The cause is very simple: [the element is not closed] Due to broken HTML tags.
 
How can this problem be solved? Two Methods: 1. Remove this on the addrssnamepage. ASPX page
<% @ Page Language = "C #" autoeventwireup = "true" codebehind = "addrssnamepage. aspx. CS "inherits =" everydaystudy. ajaxrssreader. all content other than addrssnamepage "%> is deleted, so that response. write won't have those HTML tags and page content ......
Method 2: Do not use ajax to access the Web page returned values. You can directly use the "General handler" to access the database to obtain data.
 

Generally, the processing program is similar. There are no web page tags, and naturally no broken HTML tags will be returned ^

 

I encountered a very depressing problem yesterday, and it took an hour to waste it. I am a little too fond of food ^ I need to cheer up later ^

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.