开发者

How to debug $.getJSON() .How to see what is executing on server side

I have a submit button when i click on that button i am having jQuery function which sends the Request to server side script

$('#submit_button').click(function(){
    $('#MYdialog').dialog('open');
    alert("Request Submitting");

    $.getJSON("test.php?stcode=<?php echo $this->stcode;?>",
        $("#myform").serialize(),
        function(data){
            $.ajaxSetup ({ cache: false});
            $('#MYdialog').dialog('close');

            alert(data);

            if ( data.num != null ) {
                window.open('print_test.php?stcode=01&no=' + data.num );
                window.location = self.location;
            }
        });
    }       
}); 

When i submit the request the mysubmit Dialog opened and running in loop. How 开发者_如何学Godo debug what is happening at server side script?


I highly recommend FirePHP - it allows you to put out debug messages from your PHP code that don't alter your actual response: everything gets added to the headers.


What language? If it's in asp.net you can just set a breakpoint in visual studio and trace through your server method.


To debug and see what's going on in your php script you might need to use some debugger or debug technique . This topic is covered in several questions here in SO.


You must to add a breakpoint on the server side code, not client side only. The ability to debug on server side depends pretty much on your development environment (and I'm not talking about the IDE alone)


The success handler, I believe, will never get executed if there is a problem with the server. Also if you don't return proper JSON you will get a parser error, which means no success handler.


Have you tried using Firebug in Firefox to see if it captures your call to your .php page? I use this a lot to get the "GET" calls that my site makes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜