Authentication headers are not sending JQuery Ajax

后端 未结 4 2111
粉色の甜心
粉色の甜心 2021-01-06 21:52

I have web server hosted in Apache Tomcat 7 with Basic authentication. I have Tomcat user \'tomcat\' with role \'tomcat\' and password \'tomcat\'. Following are my web.xml f

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-06 22:12

    Found that passing authentication via headers is not working with jQuery ajax with jsonp data type. So tried following and works fine.

    $.ajax({
        type: "GET",
        url: "http://tomcat:tomcat@localhost:1222/testservice/rest/test/users",
        dataType:"jsonp",
        success: function(res) {
            alert(res); 
        },
        error: function(err) {
            alert(err);
        }
    });  
    
    function callbackMethod(data) {
        alert(data);
    }
    

提交回复
热议问题