1
I installed php + apache via Xampp. PHP is working, but it doesn’t recognize Json, anyone knows if they need to enable anything in php.ini?
Returns the error: Notice: Undefined index: jsoncallback
The return line is:
echo $_GET["jsoncallback"] . '(' . json_encode("Valor=" . $teste ) . ');';
The code works, I’ve run the same code on the localhost of another computer, and also on a remote server, and it works perfectly, only on this computer that I installed via Xampp does not work.
Thank you
The problem is not in the code, as I said, it works perfectly on two servers, only in this one I installed now via Xampp that occurs this error, it is apache or php configuration.
– user3771516
I just tested on another computer now. The return when running php does not generate error. It makes the return of Json perfect. What may be missing from the other computer?
– user3771516
@user3771516 In your
php.ini
by chance check if you have the optioncgi.force_redirect = 1
. If yes, the problem may come from there, you should comment on that line and test again. (I no longer remember if it is necessary to restart, but due to doubts, restarts.)– Zuul
@user3771516 Note that JSON may be coming up with problems just because you have a
Notice
PHP that is sent together with JSON resulting in a failure to read it. You can also tell PHP not to displayNotice
although the best thing to do is what I put in the answer. Puterror_reporting(0);
at the beginning of your PHP file and should turn offnotice
.– Zuul
Now I am on a computer that does not generate the error. In ini, the cgi.force_redirect line = 1 was commented. I removed the comment from the line, and restarted Apache, but nothing has changed. Here everything is still running. If I can simulate the fault here, I discover the problem on the other computer. Any more ideas?
– user3771516
@user3771516 1. Shuts down
Notice
as I mentioned earlier and forehead. 2. Comment on the line you mentioned because it is supposed to be commented. 3. Use the browser inspector to see what is returned to you, if it is theNotice
and then JSON is because everything is working as expected but theNotice
is breaking your output, turning it off should be ok (ps: of course you are testing on the machine with the problem).– Zuul
I did some more tests, but it continues with the message. Apparently Json is running, but opening the . php, returns errors as reported above. The code used is in the post http://answall.com/questions/22497/passar-valores-para-arquivo-php-com-json
– user3771516