jquery - how to compare the result of success function of ajax with a string -


 $.ajax({         type:       "post",         url:        "test.jsp",         data:           "user="+name.val(),         success:    function(msg) {              $('#result').hide();              $("#result").html(msg)             .fadein("slow");                                if( msg =="available")                                  {                                        alert(msg);                             }           }     });  test.jsp    <h1>     <%     string user=request.getparameter("user");     if(user.equals("prerna"))     out.print("available");     else         out.print("not available");     %>    </h1> 

i want compare value returned success function compared string above code not working want add css class "#result" id. alert box not comming.

something there blank space. $.trim() function can delete blank spaces. works!!!

$.ajax({ type: "get", url: url, success: function(data) {     var result = $.trim(data);     if(result==="available"){         alert("available");     return false;     }     } }); 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -