I call a php function using jquery
$.get("tableau_trusted.php",{username:$("#username").val(),password:$("#password").val()},function(data){
alert(data);
});
Why do I return the result from the php file like this:
echo "http://$server/trusted/$ticket/$view_url?$params";
Instead of:
return "http://$server/trusted/$ticket/$view_url?$params";
I know I should use POST with the password, I’m just playing around for now.
Thanks!
Because Javascript and PHP can only communicate via HTTP. The PHP script receives an HTTP request, which is just a bunch of text. It sends back a reply, which is also just a bunch of text. The way to output this bunch of text is by
echoing it to the standard output. An AJAX request/response is exactly the same as any other normal webpage you’d write using PHP.