javascript怎么调用 后台 controller中的方法,并传递参数过去

如题所述

// 可以使用Ajax发送网络请求, 获取响应内容, 以 jQuery 为例 :

$.ajax(
    {
        url : url,     // 请求地址, 就是你的控制器, 如 test.com/home/index/index
        data : data,   // 需要传送的参数
        type : type,   // 请求方式
        dataType : '', // 返回数据的格式, 通常为JSON
        success : function(result){
            console.log(result); // 请求成功后的回调函数, result 为响应内容
        },
        error : function(){
            console.log('Send Request Fail..'); // 请求失败时的回调函数
        }
    }
);

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答