Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I have a problem in Calling Web Api using jquery
when calling Web Api using jquery

and open Console from browser Error is
ERROR
jquery-3.3.1.min.js:2 Uncaught TypeError: (h.dataType || "*").toLowerCase is not a function
    at Function.ajax (jquery-3.3.1.min.js:2:75548)
    at Object.AjaxCall (Helper.js:5:11)
    at Object.GetAll (Items.js:7:16)
    at ItemsList:2946:18


What I have tried:

JavaScript
var ClsItems = {
    
    GetAll: function () {
   
        Helper.AjaxCall(
            "https://localhost:7201/api/items",
            {},
            "json",
            function (data) {
                
                var htmlData = "";
                for (var i = 0; i < data.data.length; i++) {
                    console.log(ClsItems.DrawItem(data.data[i]));
                    htmlData +=this.ClsItems.DrawItem(data.data[i]);
                }
                console.log(htmlData)
                var d1 = document.getElementById('ItemArea');
                d1.innerHTML = htmlData;
            },
            function () { }
        );
    },

    // رسم العنصر في الصفحة
    DrawItem: function (item) {
        var rowData = `<div class="col-xl-3 col-6 col-grid-box">
            <div class="product-box">
                <div class="img-wrapper">
                    <div class="front">
                        <a href="#"></a>
                    </div>
                    <div class="back">
                        <a href="#"></a>
                    </div>
                    <div class="cart-info cart-wrap">
                        
                             ^__i class="fa fa-star"> ^__i class="fa fa-star"> ^__i class="fa fa-star"></div>
                        <a href="product-page(no-sidebar).html">
                            <h6>${item.ItemName}</h6>
                        </a>
                        <p>
                            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type en book
                        </p>
                        <h4>${item.SalesPrice}</h4>
                        <ul class="color-variant">
                            <li class="bg-light0"></li>                            <li class="bg-light1"></li>                            <li class="bg-light2"></li>                        </ul>
                    </div>
                </div>
            </div>
        </div>`;
        return rowData;
    }
};
Posted
Updated 12-Nov-23 4:11am
v2
Comments
Richard Deeming 13-Nov-23 5:26am    
Helper.AjaxCall is not a built-in method; it's something you have written.

Without seeing the source of that method, we can't help you.

1 solution

JavaScript
jquery-3.3.1.min.js:2 Uncaught TypeError: (h.dataType || "*").toLowerCase is not a function

The expression in parentheses yields a boolean value. And you cannot call toLowerCase on a boolean (i.e True or False) value.
 
Share this answer
 
Comments
A Belal 12-Nov-23 14:20pm    
Ok Eng-Richard MacCutchan Can you help me
Richard MacCutchan 13-Nov-23 3:37am    
You need to work backwards through the stack trace to find out how and where it is getting this expression, rather than some straightforward text.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900