I have a link say, https://www.dotnerpearls.net (which is wrong since it is an HTTP site by default). I need to validate this URL using an ajax call, so that if it throws an error I can show a warning that "the user should not prefix an http with an https".
tried the following,
var k = "http://www.wikipedia.org"
$.ajax({
type: 'GET',
url: k,
success: function () {
alert("success");
},
error: function () {
alert("failure");
}
});
But this always goes to error part irrespective of the url given. What am i missing ?? Pretty new to ajax, so guess its some basic thing I am missing.
the following CODE WORKED eventually:
var testUrl = "https://www.dotnetpearls.net";
$.ajax({
url: testUrl,
dataType: 'jsonp',
crossDomain: true,
timeout: 5000,
complete: function (e, xhr, settings) {
switch (e.status) {
case 200:
window.open(testUrl);
break;
default:
alert('Not Valid');
return false;
break;
}
}
});
It was the cross domain causing the error.