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条回答 默认 最新

    报告相同问题?