javascript - how to check if a file is present in htdocs folder of Apache web server -


i need check if particular file present in htdocs folder of apache web server ajax request. new ajax. please let me know if approach right.

i writing following function in javascript perform above action.

the url have considered is:"http://film.ts".

function checkurl(url){     var ajaxhttp;     if (window.xmlhttprequest){         ajaxhttp=new xmlhttprequest();     }     else{// code ie6, ie5         ajaxhttp=new activexobject("microsoft.xmlhttp");     }      ajaxhttp.open("head",url,true);     ajaxhttp.onreadystatechange=function(){         if (ajaxhttp.readystate==4 && ajaxhttp.status == 200){             data.playoutinfo._playouturls[0] = url;         }         else if(ajaxhttp.status == 404){             data.playoutinfo._playouturls[0] = "http://san_diego_clip.ts";         }     }     ajaxhttp.send();   } 

with above code getting status 200 if file not exist. please suggest me if can achieve other means.

you should use ajaxhttp.open("get",url,true); issue request. check api of xhr.open @

https://developer.mozilla.org/en-us/docs/dom/xmlhttprequest

it's

void open(    domstring method,    domstring url,    optional boolean async,    optional domstring user,    optional domstring password ); 

so , got 200 time head request.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -