jQuery AJAX调用不起作用

时间:2017-10-14 04:04:11

标签: jquery ajax

检查下面的AJAX调用。问题是AJAX帖子没有向我的方法发送数据" / CategoryResearch / Search"一点都不根据我的检查,我没有看到任何错误。

如果您发现任何问题,请告诉我。

提前致谢

<script>    
  $(document).ready(function () {
    var _OperationName = "";
    var _calltype = "";
    var _page = "";
    var _keywords = "";
    var _type = "";
    var _location = "";
    var _condition = "";
    var _min = "";
    var _max = "";
    var _negative = "";
    var _minFeedback = "";
    var _maxFeedback = "";
    var _drange = "";
    var _categoryId = "";

    $(".SearchMainCategory, .SearchSubCategory").click(function () {
      _categoryId = $(this).find("#SearchLevel1CatId").val();
      if (typeof _categoryId === "undefined") {
        _categoryId = $(this).find("#SearchLevel2CatId").val();
      }

      _OperationName = "findItemsByCategory";
      _calltype = "categoryClick";
      _page = 1;

      $.post("/CategoryResearch/Search", 
        { 
          OperationName: _OperationName, 
          calltype: _calltype,
          page: _page, 
          keywords: _keywords, 
          type: _type, 
          location: _location, 
          condition: _condition, 
          min: _min, 
          max: _max,
          negative: _negative, 
          minFeedback: _minFeedback, 
          maxFeedback: _maxFeedback, 
          drange: _drange, 
          categoryId: _categoryId 
        }, 
      StartLoading())
      .done(function (data) {});    
    });   
  });
</script>

3 个答案:

答案 0 :(得分:1)

从你的评论中,我发现你正在调用一个未定义的函数&#34; StartLoading()&#34;所以我删除了,现在它可以工作。

<script>

    $(document).ready(function () {
        var _operationname = "";
        var _calltype = "";
        var _page = "";
        var _keywords = "";
        var _type = "";
        var _location = "";
        var _condition = "";
        var _min = "";
        var _max = "";
        var _negative = "";
        var _minFeedback = "";
        var _maxFeedback = "";
        var _drange = "";
        var _categoryId = "";

        $(".SearchMainCategory, .SearchSubCategory").click(function () {
            _categoryId = $(this).find("#SearchLevel1CatId").val();
            if (typeof _categoryId === "undefined") {
                _categoryId = $(this).find("#SearchLevel2CatId").val();
            }

            _operationname = "findItemsByCategory";
            _calltype = "categoryClick";
            _page = 1;

            $.post("/CategoryResearch/Search", { OperationName: _operationname, calltype: _calltype, page: _page, keywords: _keywords, type: _type, location: _location, condition: _condition, min: _min, max: _max, negative: _negative, minFeedback: _minFeedback, maxFeedback: _maxFeedback, drange: _drange, categoryId: _categoryId })
                .done(function (data) {




                });


        });



    });
</script>

答案 1 :(得分:0)

来自控制台的错误表明您没有定义回调函数startloading。

您可以创建一个空的匿名函数

function(){} 

代替'startloading'进行测试。如果它可以工作,那么您可以将空函数替换为您打算使用startloading执行的预期实现

答案 2 :(得分:0)

从截图中可以看出StartLoading方法未定义。

$.post中的第三个参数需要function。您似乎正在执行函数StartLoading而不是将其作为函数引用传递。

  1. 检查是否已定义StartLoading
  2. StartLoading作为StartLoading之类的参考,而不是()