is this script correct?

Discussion in 'JavaScript' started by Joseph S, Apr 16, 2012.

  1. #1
    I have a piece of coding that I feel it is wrongly codded. It shows everything as "success".

    function URLSubmit(url,data,str){	
    	$.ajax({
                url: url,
                type: 'POST',
    			data: data,
    			beforeSend:function(){
    					$("#"+str+"_State").html("Please wait...");
    				},
    			complete:function(){
    					$("#"+str+"_State").html("<img src='/images/right.gif'>");
    				},
    			success:function(msg){
    			   if (msg!=""){			
    			    $("#"+str+"_State").html("<img src='/images/right.gif'>");
    			   }else{
    				   alert(msg);
    			   }
    			  }
    		});
    	
    }
    Code (markup):
    Those of you who are experts in this kind of coding, could you please tell me if I am wrong or not?

    Thanks.
     
    Joseph S, Apr 16, 2012 IP
  2. joetito1

    joetito1 Member

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    Unless your call to url was bad, or didn't work, you'll end up in success.
     
    joetito1, Apr 30, 2012 IP