Hi, I am looking for some help debugging jQuery being used with PHP in
the way described. I basically want a way of tracing where it gets to
in the PHP because the usual methods of writing out statements to the
page or embedding javascript alerts are not available to me in this
scenario. I will now explain.

I have some PHP (in a file called addToProj.php) which relies on the
last 3 lines of code being something similar to the following so that
jQuery can pick up returned data (including data for debugging
purposes)

                $json_array["status"]="point end";
                echo json_encode($json_array);
?>

The jquery looks something like this, with the unimportant lines
removed.....

                $(".actionOptAdd").bind("click",
                        function()
                        {
.
.
.
                                $.getJSON('lib/addToProj.php',
                                {....}, function(data)
                        }, function(data)
                                {
                                   $.each(data, function(i,item)
                                   {
                                    if ( i == "status" )$('#field).val(item);
                                   });
                                });
                        }
                );
//===========================
I am using json to return data to the jQuery (at the end of the day I
will need to return more than one data item) and then updating a field
on my html page. At the moment the return data is just for tracking
down where I have got to in the PHP. I should point out that I can't
insert statements like

echo "<script type='text/javascript'>alert('got here xx');</script>";

in my PHP (for some strange reason) to debug the PHP. Also, I can't
place lines like

                $json_array["status"]="message for debugging";
                echo json_encode($json_array);
                return();

at various points in the php, because it breaks the code. Also just
doing print '<p>something</p>'; can't be done in this case.

Has anyone got an idea of how I can solve the above. Your replies will
be greatly appreciated.
What is the easiest way of

Reply via email to