pass data from php-jquery, data within function not passed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

pass data from php-jquery, data within function not passed

Post by scarface222 »

hey guys, quick question, I have a function running in php and I am trying to pass json encoded information to the original page. It works fine except when I am doing checks within a function, then for some reason the information is not passed back. Was wondering if anyone had an idea why.

This is my success function

Code: Select all

success:        function(response, status){
                  alert(response.error);
              }
this is an example of executing the add command, only the 3 data array values message,time, and name outside the insert message function are defined and successfully passed back. The error messages I try to pass back within the insertMessage function when it is run are not for some reason. For example, within the function, $data['error']='test';

Code: Select all

case 'add':
        $time = time();
            insertMessage($_POST['name'], $_POST['message'], $_POST['topic_id']);
              $data['name'] = $_POST['name'];
      $data['message'] = $_POST['message'];
      $data['time'] = $time;
            break;
require_once('JSON.php');
  $json = new Services_JSON();
  $out = $json->encode($data);
  print $out;
Post Reply