最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught TypeError: Cannot read property 'msie' of undefined is the error - Stack Overflow

programmeradmin2浏览0评论

I keep getting

Uncaught TypeError: Cannot read property 'msie' of undefined

when I try to console log a view from couchdb. I'm new to coding and I don't know what this error means. When I use an ajax call to basically do the same thing it works and pulls the view from my couch database. This is for school so I need to get the couch call working. thanks for any help.

HTML:

<html>

<head>
    <title>SK8
        TEAMS</title>
    <meta charset="utf-8"/>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="css/jquery.mobile.flatui.css"/>
    <script src="jquery-1.9.1.min.js"></script>
    <script src="jquery.mobile-1.3.2.min.js"></script>
    <link rel="stylesheet" href="style/main.css"/>
</head>

<body>

    <section data-role="page" id="home" data-theme="c">
         <section data-role="header" data-position="fixed">
            <h1>Home</h1>
            </section>
            <section data-role="content" class="ui-body-c">
                <ul id="homeItems" data-role="listview">
                </ul>
             </section>
         </section>

     <script src="jquery.couch.js"></script>
     <script src="my.js" type="text/javascript"></script>
</body>

JAVASCRIPT:

$(document).on('pageinit', '#home',
    function () {
        $.couch.db("sk8team").view("app/pany", {
            success: function (data) {
                console.log(data);
            }
        });
    });

I keep getting

Uncaught TypeError: Cannot read property 'msie' of undefined

when I try to console log a view from couchdb. I'm new to coding and I don't know what this error means. When I use an ajax call to basically do the same thing it works and pulls the view from my couch database. This is for school so I need to get the couch call working. thanks for any help.

HTML:

<html>

<head>
    <title>SK8
        TEAMS</title>
    <meta charset="utf-8"/>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="css/jquery.mobile.flatui.css"/>
    <script src="jquery-1.9.1.min.js"></script>
    <script src="jquery.mobile-1.3.2.min.js"></script>
    <link rel="stylesheet" href="style/main.css"/>
</head>

<body>

    <section data-role="page" id="home" data-theme="c">
         <section data-role="header" data-position="fixed">
            <h1>Home</h1>
            </section>
            <section data-role="content" class="ui-body-c">
                <ul id="homeItems" data-role="listview">
                </ul>
             </section>
         </section>

     <script src="jquery.couch.js"></script>
     <script src="my.js" type="text/javascript"></script>
</body>

JAVASCRIPT:

$(document).on('pageinit', '#home',
    function () {
        $.couch.db("sk8team").view("app/pany", {
            success: function (data) {
                console.log(data);
            }
        });
    });
Share Improve this question edited Aug 8, 2013 at 4:51 Praveen 56.6k35 gold badges136 silver badges166 bronze badges asked Aug 8, 2013 at 4:30 user2562740user2562740 411 silver badge4 bronze badges 2
  • Do you mean modernizer? – user2562740 Commented Aug 8, 2013 at 5:26
  • I tried to use an older version of jquery but I keep getting the error. I've tried migrate an modernized. When I move my scripts around the msie error goes away but then I get a method "db" is undefined as if my database doesn't exist. If anyone has any other suggestions I would greatly appreciate it. – user2562740 Commented Aug 8, 2013 at 13:47
Add a ment  | 

3 Answers 3

Reset to default 5

I also had similar error, but I solved it. It's a piece of code I got from Stack Overflow. Just paste it in your script. And download the latest version of jQuery. I used jquery-1.10.2.js.

JavaScript:

 jQuery.browser = {};
 (function () {
    jQuery.browser.msie = false;
    jQuery.browser.version = 0;
    if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
       jQuery.browser.msie = true;
       jQuery.browser.version = RegExp.$1;
  }
 })();

Did a little more research, the issues is couch is not patible with JQuery 1.9, try an older version of JQuery or using the browser support plugin.

$.browser removed in jQuery 1.9 you can use either navigator.userAgent or jQuery.migrate plugin.

https://github./jquery/jquery-migrate/

发布评论

评论列表(0)

  1. 暂无评论