This is not possible in the browser, but if you have to make an ajax request to your web server, you can ask him to do a check.
Client code
$.ajax({ url: "urltest.py", cache: false, dataType: "text" success: function(data){ if(data === "SUCCESS"){ //do things } else { //else do other things } } });
Server code
def call_server(self, url): headers = {'Content-Type': 'application-json' , 'Accept' : 'application-json' , 'Accept-Encoding' : 'gzip, deflate' } r = requests.get(url) if r.status_code == 200: print "SUCCESS" else: print "No soup for you"
Not tested or anything else, but you understood the idea.
Mike m
source share