400(错误请求)JQuery自动完成WebMethod调用

时间:2016-10-11 17:42:29

标签: javascript c# jquery asp.net jquery-ui-autocomplete

当我尝试将此WebMethod称为JQuery自动完成时,我遇到400(错误请求)。我在其他帖子上试过这些解决方案,但它们似乎没有用。这是我的代码。 webmethod应该不带参数,并从同一目录中的csv文件返回JSON字符串。我试图做很多事情来防止出现这个错误,但似乎都没有。

C#

SELECT pt.product_name,
       pt.company_id,
       (SELECT MIN (price)
          FROM cake_table ct
         WHERE     ct.product_code = pt.product_code
               AND ct.weight = (SELECT MIN (sub.weight)
                                  FROM cake_table sub
                                 WHERE sub.product_code = ct.product_code))
           cake_price
  FROM base_product_table pt

JQuery的

( (SELECT pt.product_name,
          pt.company_id,
          (SELECT MIN (price)
             FROM cake_table ct
            WHERE     ct.product_code = pt.product_code
                  AND ct.weight = (SELECT MIN (sub.weight)
                                     FROM cake_table sub
                                    WHERE sub.product_code = ct.product_code))
              cake_price
     FROM base_product_table pt
    WHERE EXISTS
              (SELECT 'X'
                 FROM cake_table ck
                WHERE ck.product_code = pt.product_code))
 UNION ALL
 (SELECT pt.product_name,
         pt.company_id,
         (SELECT MIN (price)
            FROM wraps_table ct
           WHERE     ct.product_code = pt.product_code
                 AND ct.weight = (SELECT MIN (sub.weight)
                                    FROM wraps_table sub
                                   WHERE sub.product_code = ct.product_code))
             cake_price
    FROM base_product_table pt
   WHERE EXISTS
             (SELECT 'X'
                FROM wraps_table ck
               WHERE ck.product_code = pt.product_code)))

1 个答案:

答案 0 :(得分:0)

请尝试

data: '{}',  

而不是

data: JSON.stringify({}),