Call php from javascript and return an array from php to Javascript function

后端 未结 9 1629
孤街浪徒
孤街浪徒 2020-12-03 13:22

I want to write a function in javascript which will call the Getfilename.php and Get the $filesArray that is return in javascript.

GetFilenme.php is another file and

9条回答
  •  孤城傲影
    2020-12-03 13:35

    If your not using a javascript framework like jquery or prototype then you will have to create a XMLHttpRequest object yourself which the javascript framework would normally wrap up. Something like the following:

    function GetHttpObject() 
    {
        if (typeof XMLHttpRequest != 'undefined')
            return new XMLHttpRequest();
    
        try 
        {
            return new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                return new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) {}
        }
    
        return false;
    }
    

提交回复
热议问题