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 :)

Recommended Answers

All 2 Replies

try changing: if (null == server_msg) to: if (!/a-z/i.test(server_msg))

Maybe..

if(server_msg.replace(/^\s+|\s+$/g, '') == "null")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.