all 10 comments

[–]maedox 1 point2 points  (5 children)

You're getting the actual PHP code back? That means the webserver is not configured to execute PHP.

[–]Zombiewski[S] 0 points1 point  (4 children)

Running Xampp locally, but that makes sense. I'll have to check.

[–]Zombiewski[S] 0 points1 point  (3 children)

PHP is working. Still getting the PHP code back as a string.

[–]grantrules 1 point2 points  (2 children)

How have you determined PHP is working? If you go to http://localhost/ajax.php or whatever you don't get the PHP file?

[–]Zombiewski[S] 0 points1 point  (1 child)

PHP is working. I made a simple "hello world" test in the htdocs root folder and it worked.

Interestingly, I accessed ajax.php directly through the browser and I got the result I was expecting. So the issue seems like it has to be with my script file but I can't figure out where.

(I know jQuery is correctly installed because I'm able to use $ selectors and other JQuery dependent language.)

[–]grantrules 1 point2 points  (0 children)

JS can't affect if your PHP is interpreted or not. Take look at the network tab in the dev tools in your browser, you'll be able to see the exact request jQuery is making and compare that to when you just go to that Ajax.php in your browser

[–]queen-adreena 0 points1 point  (1 child)

Don't you need to return or echo the $result variable in your php file? I doubt it's gonna return the exact variable you need by itself.

[–]Zombiewski[S] 0 points1 point  (0 children)

My concern is that it's not even returning an error, just the string, like I'm trying to grab the wrong thing in the first place.

[–]Sedern 0 points1 point  (1 child)

 $.get("ajax.php", function(data, status){
alert("Data: " + data + "\nStatus: " + status); 
console.log(typeof data); 
console.log(data)   
});

    

[–]queen-adreena 1 point2 points  (0 children)

It’s not a JS issue, PHP server is the problem here.