开发者

How Does the $.getJSON success function Works

I have php outputting a JSON Messages in this manner when the Wrong information is incorrect {"error":"Wrongparameter"}{"seatno":"8989"}.So the Wrong info can be shown on th开发者_Go百科e Jquery Modal. "message" is nothing but the php exception caught.

This Message Comes when all the Correect Information has been entered and Seat number is generated

{"seatno":"8989"}

$.getJSON("test.php?cde="+code,
                        $("#form1").serialize(),                        
                        function(data){ 
                            alert("Inside");                        
                            $('#dialog1').dialog('close');                                                                                      
                            if ( data.seat != null )
                            {
                                //Do Some Processing.                               
                            }else{
                                $("#div1").removeAttr('style');
                                $("#div1").text("Error" + data.error);
                            }                           
                         });

does the Anonymous $getJson() function work only when the Correct data is genretaed . I am not able to get the "error" generated in json into The Dialog which is in else part


I think you should use another format in your response, something more like:

{ 'error': 'Wrongparameter', 'seatno': '8989' }

The problem is that you're trying to access data as a single object, but you're returning 2 objects in the response.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜