tmyonline Posted April 29, 2009 Share Posted April 29, 2009 Hi Guys, My Ajax works fine on my Window machine but when I uploaded it to the server, it failed. Below is the code on the server: <?php class Message { public $messOrder; public $subject; public $content; } ... $message = new Message(); $message->messOrder = $mailRow['messOrder']; ... print(json_encode($message)); ?> When debugging, I saw it complain "call to the undefined function json_encode()", the last line above. I don't get it. It works fine on my machine though. Any idea ? Thanks. Link to comment https://forums.phpfreaks.com/topic/156114-problem-with-ajax-on-server/ Share on other sites More sharing options...
RichardRotterdam Posted April 29, 2009 Share Posted April 29, 2009 json_encode is available for php 5.2.0 and higher it's most likely not available because you are running a lower version of php. A work around i use is listed on the manual page and starts with if (!function_exists('json_encode')) Link to comment https://forums.phpfreaks.com/topic/156114-problem-with-ajax-on-server/#findComment-821767 Share on other sites More sharing options...
tmyonline Posted May 1, 2009 Author Share Posted May 1, 2009 Thanks Dj Kat. It may be it. I tried your work-around solution if (!function_exists('json_encode')) print(json_encode($message)); but it didn't work. Do you have a link to the manual page so I can find out more about it ? Thanks. Link to comment https://forums.phpfreaks.com/topic/156114-problem-with-ajax-on-server/#findComment-823424 Share on other sites More sharing options...
Ken2k7 Posted May 1, 2009 Share Posted May 1, 2009 No no, you got it mixed up. Think! if (function_exists('json_encode')) print(json_encode($message)); Link to comment https://forums.phpfreaks.com/topic/156114-problem-with-ajax-on-server/#findComment-823439 Share on other sites More sharing options...
RichardRotterdam Posted May 1, 2009 Share Posted May 1, 2009 I didn't gave the code to the working solution it was a part of it so you would know what to look for. here is the link to the direct script http://nl2.php.net/manual/en/function.json-encode.php#82904 Link to comment https://forums.phpfreaks.com/topic/156114-problem-with-ajax-on-server/#findComment-823685 Share on other sites More sharing options...
tmyonline Posted May 6, 2009 Author Share Posted May 6, 2009 Thanks Dj Kat. Thanks again. Link to comment https://forums.phpfreaks.com/topic/156114-problem-with-ajax-on-server/#findComment-827876 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.