I am newbie to jQuery/AJAX. I have a small application for testing pupose that has a button on it. When the button is clicked a connection is made to a server located in the same domain to get some data and alert it.
Problem: My application can't make any connection to the server. The following screen shot is from the developer tools in google chrome.
The server has its own self signed certificate. If I connect to the server via web browser I get an SSL certificate warning as shown below.
If I click on proceed and then login to the server, after this now my application is also able to retieve the data from the server.(If I click the button on my web app it alerts the data it got from the server.)
Question: Is there any workaround for this, can I bypass this error? Why it works once I have logged in to the server via web browser? My app will be used locally in the same domain and it is not a public app.
jQuery Code: I have this code:
$('#mybutton').click(function(){
$.ajax({
type: "GET",
url: "https://192.168.150.33/Api/loc?jsonpCallback=myCallback",
dataType:"jsonp",
async: false,
beforeSend: function (request){
request.withCredentials = true;
request.setRequestHeader("Authorization", "Basic " + btoa('admin' + ":" + 'password'));
},
success: function(response){
alert('hi');
},
});
});
function myCallback(response){
data= JSON.stringify(response)
alert(data)
Here is a post that addresses the same issue. As far as I understood this post according to it there is no solution. Any suggestions will be helpful. Thanks