相关疑难解决方法(0)

如何在JavaScript中将字符串编码为Base64?

我有一个PHP脚本,可以将PNG图像编码为Base64字符串.

我想用JavaScript做同样的事情.我知道如何打开文件,但我不知道如何进行编码.我不习惯使用二进制数据.

javascript base64

745
推荐指数
27
解决办法
102万
查看次数

在Internet Explorer 9中更改域名后,Ajax停止工作

我们正在开发一个使用html5,jQuery(1.8.2)和jQuery mobile的移动网站,同时进行jQuery ajax调用(get和post).
在我们更改了域名后,我们对ie9上的ajax调用进行了"拒绝访问".
我们试图包括jquery.iecors.js.但我们仍然得到同样的错误.这有什么解决方案吗?

示例代码:

$.support.cors = true;

$.ajax({
    cache: false,
    async: true,
    crossDomain: true,
    timeout: 600000,

    url: baseUrl + '/SmartTouch/restServices/PrefferedHotels',
    type: 'GET',

    beforeSend: function (xhr) {
        xhr.setRequestHeader("Authorization", "Basic " + myencoded);
    },
    contentType: "application/x-www.form-urlencoded; (http://www.form-urlencoded;) (http://www.form-urlencoded;) charset=UTF-8",
    success: function (data) {

        alert("success");
    },
    error: function (jqXHR, textStatus, errorThrown) {


        alert("error!!::" + JSON.stringify(jqXHR));

        alert('response: ' + jqXHR.responseText);
        alert('code: ' + jqXHR.getResponseHeader('X-Subscriber-Status'));
        alert("textStatus " + textStatus);
        alert("errorThrown " + errorThrown);

    }
});
Run Code Online (Sandbox Code Playgroud)

编辑:

beforeSend: function (xhr) {
    xhr.setRequestHeader("Authorization", …
Run Code Online (Sandbox Code Playgroud)

javascript css ajax jquery-mobile

7
推荐指数
1
解决办法
1259
查看次数

标签 统计

javascript ×2

ajax ×1

base64 ×1

css ×1

jquery-mobile ×1