Jquery.get return php code?

I am trying to use the jquery ajax $ .get (...) function to send a request to my server and return some data to it. I am using the following code:

$.get("php/getRocks.php", { name: "John", time: "2pm" },
    function(data){
    alert("Data Loaded: " + data);
});

Instead of returning the data, it simply returns the entire php file as a string. Am I doing something wrong? Thanks for the help.

+3
source share
4 answers

Well, it looks like I solved the problem, sort of. Apparently, if I access the local site, php does not work, but if I use the domain name, it does it. Does anyone know why? Or better yet, a way to fix it?

Thank you all for your help!

0
source

PHP ? . - .php , PHP- .

:

, , , , . -, , php , , . - , ? , ?

!

( ​​ ) PHP , . , . , Uniform Server, .

+8

( MAMP mac), , .

, , - / . url getRocks.php( script ), ( ), php/getRocks.php, ( php- ).

, MAMP - ? , , , .

+1

. , php

linux/apache2 php 5 / apache php dso :

LoadModule php5_module        modules/libphp5.so

, jQuery, / -:

apache, , conf:

AddType application/x-httpd-php .php

More details about php and apache if you use php anad apache on linux / nix, for example: http://dan.drydog.com/apache2php.html

0
source

Source: https://habr.com/ru/post/1714692/


All Articles