weixin_33725515 2015-05-15 14:20 采纳率: 0%
浏览 26

CORS AJAX网域保留要求

I have a url that is returns the xml data and it is uses the url with username and password.

$.ajax({
    url: 'http://myserver.com:port/BC/rest/productslist/',
    data: {
        'username': 'username', 
        'password': 'password'
    },
    dataType: "jsonp", // for cross domain
    contentType: "application/xml; charset=UTF-8",
    type: 'GET',
    crossDomain: true,
    beforeSend : function(xhr) {
        xhr.setRequestHeader("Authorization", "Basic" + window.btoa("username" + ":"+ "password"));
    },    
    success: function(sucessResponse) { 
        alert('PUT completed' + sucessResponse); 
    } ,
    error: function(failResponse){
        alert("Error: Something went wrong" + JSON.stringify(failResponse));
    }   
});

Problem: When I am testing the code it is showing the error:

Uncaught SyntaxError: Unexpected token <' error.

Any suggestions? Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 python忆阻器数字识别
    • ¥15 无法输出helloworld
    • ¥15 高通uboot 打印ubi init err 22
    • ¥20 PDF元数据中的XMP媒体管理属性
    • ¥15 R语言中lasso回归报错
    • ¥15 网站突然不能访问了,上午还好好的
    • ¥15 有没有dl可以帮弄”我去图书馆”秒选道具和积分
    • ¥15 semrush,SEO,内嵌网站,api
    • ¥15 Stata:为什么reghdfe后的因变量没有被发现识别啊
    • ¥15 振荡电路,ADS仿真