Link to home
Start Free TrialLog in
Avatar of roy_sanu
roy_sanuFlag for India

asked on

how to make ajax call on click event

is this the correct approach

 $( "#rights").click( function() {
	  alert("sanu");
	  $.ajax({
          type: "GET",
          dataType: "json",
          url: "/tile/mainRights.html",
      
          success: function(json,sttext,response) {
        	  
          }
          if(json != null && json.length > 0) {
        	  
        	  for(i = 0; i < json.length; i++) {
        	       var obj = json[i].code;
        	       var obj1 = json[i].descrip;

          
         }
});

Open in new window

Avatar of jayakrishnabh
jayakrishnabh

$( "#rights").click( function() {
 $.ajax({
                    type: 'GET', //or POST
                    url: 'WebForm1.aspx/MyMethod',
                    data: { },
                    dataType: 'json',
                    contentType: 'application/json; charset=utf-8',
                    success: function(data){
                            //do ur stuff here from data
                     }
                });
});
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial