jquery中Get方法请求接口

$.ajax(
                {
                    url: apiUrl + '/api/Code/GetCodeProductInfo',
                    type: 'GET',
                    //Header头部添加Token参数
                    beforeSend: function (request) {
                        request.setRequestHeader("Token", token);
                    },
                    dataType: 'text',
                    data: { code: $("#packCode").val() },
                    success: function (data) {
                        data = eval('(' +data+ ')');
                        console.log(data.data);
                        if (data.code == 200) {
                            $("#product_code").text(codeUrl);
                            $("#register_code").text(data.data.registerCode);
                            $("#generic_name").text(data.data.genericName);
                            $("#shap").text(data.data.shap);
                            $("#production_style").text(data.data.productionType);
                            $("#production_date").text(data.data.productionDate);
                            $("#production_batch").text(data.data.batchNo);
                            $("#fit_crop").text(data.data.fitCrop);
                            $("#description").text(data.data.description);
                            $("#entName").text(data.data.entName);
                            productName = data.data.genericName;
                            $("#fangwei").attr("href", "check.html?productName=" + productName + "&code=" + codeUrl);
                            $("#viewMore").attr("href", "main.html?productName=" + productName + "&code=" + codeUrl);
                        }
                    },
                    error: function (data) { console.log("error"); }
                }
            );
原文地址:https://www.cnblogs.com/siyunianhua/p/10644784.html