web前端
    jQuery iframe高度自适应内容
    1
    $("#content-frame").load(function(){
    2
    var content_height = $(this).contents().find("body").height();
    3
    $(this).height(content_height);
    4
    });
    Copied!
    ajax跨域cookie问题
      "Access-Control-Allow-Origin":"*"
      解决浏览器对前端的拦截
      xhrFields: {withCredentials: true},
      允许使用cookie
      example
      ```javascript
      function loadValidCode(id) {
      $.ajax({
      1
      url: "http://110.64.69.66:8081/team/valid_code",
      2
      processData: false,
      3
      xhrFields: {withCredentials: true}
      4
      }).always(function (data) {
      5
      console.log('test');
      6
      $(id).attr('src', "data:image/gif;base64," + data);
      7
      }
      8
      );
      Copied!
} $('#reg_btn').click(function () { $.ajax({ type: "post", url: "http://110.64.69.66:8081/team/register/", dataType: "json", data: { "mail": $('#r_mail').val(), "pwd": $('#r_pwd').val(), "inv": $('#r_inv').val(), "code": $('#r_code').val() }, xhrFields: {withCredentials: true}, headers: { "Access-Control-Allow-Origin":"*" }
1
}).always(function (data) {
2
console.log(data);
3
});
Copied!
```
    另一方面还需要后端配合,具体查看各种后端的相关配置
最近更新 2yr ago
复制链接