使用jQuery ajax向后台传递参数para=1+1时后台接收到的参数为para=1 1,解决方案是 使用json传递,代码如下。

var url = "/test/check";
    $.ajax({
        type: "post",
        url: url,
//      data: "para=1+1",  data为字符串时 后台接收到的参数为 1 1
        data: {"para":1+1}, // data为json数据时 后台接收到的参数为 1+1
        cache: false,
        async : false,
        dataType: "json",
        success: function (data ,textStatus, jqXHR)
        {
            if("true"==data.flag){
               alert("合法!");
                return true;
            }else{
                alert("不合法!错误信息如下:"+data.errorMsg);
                return false;
            }
        },
        error:function (XMLHttpRequest, textStatus, errorThrown) {      
            alert("请求失败!");
        }
     });

相关文章:

  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
猜你喜欢
  • 2021-10-11
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案