Friday, March 10, 2017

Run PHP using AJAX in Laravel

I am trying to use AJAX code provided by w3schools.com in Laravel framework

 function showHint(str) {
    if (str.length == 0) { 
        document.getElementById("txtHint").innerHTML = "";
        return;
    } else {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                document.getElementById("txtHint").innerHTML = this.responseText;
            }
        }
        xmlhttp.open("GET", "gethint.php?q="+str, true);
        xmlhttp.send();
        }
    }

... but I don't really know how to correctly reference/call it.

Can someone please help me by pointing out where to place php file and how to correctly write path for it or what ever else is needed? (I am trying to call it from view)



via NoOorZ24

Advertisement