$.ajax({
                        beforeSend: function(xhr) {
                             xhr.setRequestHeader("companyId", "1");
                            },

                            type: "post",
                            url: base_url + "visitor/insertVisitorByCode",
                            data: params, //
                            dataType: 'json',
                            xhrFields: {     
                                withCredentials: true   
                            },
                            crossDomain: true,
                            success: function(data) {
                                console.log("提交返回数据");
                                console.log(data);
                                if(data.code == "WX5000") {
                                    setTimeout(function() {
                                        toastr.info("请勿重复邀请");
                                        return false;
                                    }, 1000);
                                } else if(data.code == "411") {
                                    setTimeout(function() {
                                        toastr.info("该组织中不存在接待人");
                                        return false;
                                    }, 1000);
                                } else if(data.code == "AUTH0000") {
                                    toastr.info("登记成功");
                                    setTimeout(function() {
                                        // 先清空之前的缓存
                                        localStorage.clear();
                                        localStorage.setItem('info', JSON.stringify(info));
                                        window.location.href = "autoInfo.html";
                                    }, 1000);
                                };
                            }
                        });

下面是运行结果

ajax请求中设置自定义请求头

相关文章:

  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2021-11-28
  • 2021-11-28
  • 2021-11-28
猜你喜欢
  • 2021-04-17
  • 2021-11-28
  • 2021-11-28
  • 2021-12-05
  • 2021-11-28
  • 2021-11-28
相关资源
相似解决方案