Counteraller event by js



  • How do you call the counterall method? Assortiment by means of a violin, and by giving it the Category. When pressed on the button, there's a mistake.

    Uncaught ReferenceError: $ is not defined
    sort_submit @ Assortiment?Category=all:43
    onclick @ Assortiment?Category=all:40   
    

    cshtml:

    <input id="Category" onfocus="if (this.value == '@ViewBag.Category') {this.value = ''; this.style.color = '#000';}"
        onblur="if (this.value == '') {this.value = '@ViewBag.Category'; this.style.color = '#777';}"
        type="text" value=@ViewBag.Category />
    <input onclick="sort_submit(Category)" type="button" value="Sort" />
    <script>
        function sort_submit(Category) {
            $.ajax({
                url: '/Admin/Assortiment',
                type: 'POST',
                data: { Category: Category },
                success: null
            })
        }
    </script>
    

    Controller:

    public ActionResult Assortiment(String Category)
    {
        if (Category == "all" || Category == null)
        {
            Item[] items = DBProvider.getAllItems();
            ViewBag.items = items;
            ViewBag.Category = "Category";
            return View();
        }
        else
        {
            Item[] items = DBProvider.getItemsByCategory(Category);
            ViewBag.items = items;
            ViewBag.Category = Category;
            return View();
        }
    }
    

    upd:

    Uncaught TypeError: Illegal invocation
    e @ jquery-1.11.3.min.js:5
    Vb @ jquery-1.11.3.min.js:5
    Vb @ jquery-1.11.3.min.js:5
    Vb @ jquery-1.11.3.min.js:5
    m.param @ jquery-1.11.3.min.js:5
    m.extend.ajax @ jquery-1.11.3.min.js:5
    sort_submit @ Assortiment?Category=all:44
    onclick @ Assortiment?Category=all:41
    

    44 line : $.ajax({



  • If Category variable is:

    <input onclick="sort_submit('@Category')" type="button" value="Sort" />
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2