logicslab Posted November 29, 2010 Share Posted November 29, 2010 Hi Friends, I am come with a new query in jQuery. I have a listing form in which the details showed , the View more Details is implemented using Ajax. When Click "+" sign there is a loading image show First then the Result show there ... It's all working Fine , But I need a way to show Error I mean some time Server Response is success with Empty String on that time I need to catch same .... I explain code Below: if(proceed) { $.ajax({ type: "POST", data: "key="+id, dataType: 'json', async: true, url: "<?php echo site_url(); ?>/server/view_serverdet/", beforeSend: function() { $('#view_load'+id).show(); $('#view_load'+id).addClass(class); }, complete: function(){ $('#view_load'+id).hide(); } }, success: function (server_msg) { if (null == server_msg) { var warning = "<font color=\"red\">Unable to load server details</font>"; $('#view_load'+id).html(warning); } else { // Working Fine! } But that error Just Show and Hide ... How I can show that Error there, If you have any idea , pls help me ASAP... Thankfully Anes P.A Link to comment https://forums.phpfreaks.com/topic/220126-need-to-catch-error-in-success-function-in-jquery/ Share on other sites More sharing options...
trq Posted November 29, 2010 Share Posted November 29, 2010 But that error Just Show and Hide ... How I can show that Error there, If you have any idea , pls help me ASAP... Sorry, but that makes little sense. what exactly do you want to do? Link to comment https://forums.phpfreaks.com/topic/220126-need-to-catch-error-in-success-function-in-jquery/#findComment-1140867 Share on other sites More sharing options...
RichardRotterdam Posted November 29, 2010 Share Posted November 29, 2010 As stated before your description is quite hard to understand. However I do see something in your code that in your code that makes me think that your looking for the error handler of the ajax object. In your code I see this : var warning = "<font color=\"red\">Unable to load server details</font>"; To see if an error occurs try something like: $.ajax({ success: function() { // your normal action when the server call is running as expected }, error: function() { // your code when a error occurs on the server such as a timeout } }); if this was not what you were looking for can you try again describing your exact problem? Link to comment https://forums.phpfreaks.com/topic/220126-need-to-catch-error-in-success-function-in-jquery/#findComment-1140937 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.