In IE8, when Jquery obtains the selected select value, post it to the background to report an error.

Source: Internet
Author: User

When jquery is used to obtain the select statement, it is generally used as follows:

<Select id = 'A'> <option selected = 'selected' value = '1'> </select> var selectedValue = $ ("# a"). val ();

In non-IE8, the value of selectedValue is "1", and the typeof selectedValue is "string ".

In IE8, the value of selectedValue is ["1"], and the typeof selectedValue is "objectg ".

If selectedValue post is directly sent to the background, an error is reported when the background receives the post because selectedValue in IE8 is regarded as an array during transmission and cannot be identified in the background.

The solution code is as follows:

SelectedValue = typeof selectedValue = "object "? SelectedValue [0]: selectedValue;

In this way, selectedValue is a string.

In addition, this will cause other problems:

Var a = selectedValue. trim ();

This Code cannot be executed in IE8, possibly because of the above.

Run the following code:

$. Trim (selectedValue );

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.