2014-11-01 118 views
-1

(function(){$('。KisiSilici')。click(function(){ does not working .click,.on,.live,is my try but not work。Thanks for your help 。ajax选择性不工作

也许是因为我填写表格与阿贾克斯

$(document).ready(function Kisilertabs() { 
 
       $(function() { 
 
        $("#tabs").tabs(); 
 
       }); 
 
       var id = @Model.ID.ToString() 
 
       $.ajax({ 
 
        url: '@Url.Action("Kisiler", "Cihazlar")', 
 
        type: "get", 
 
        contentType: "application/json; charset=utf-8", 
 
        data: { data: id }, 
 
        dataType: "json", 
 
        success: function (data) { 
 
         var row = "<tr><th width='70'>S. No</th><th width='220'> Adı </th><th width='220'>Soyadı</th><th>Sicil No</th><hr/></tr>"; 
 
         $.each(data, function (index, item) { 
 
          row += "<tr id='" + item.ID + "'><td>" + item.ID + "</td ><td>" + item.Adi + "</td><td>" + item.Soyadi + "</td><td>" + item.Sicil + "</td><td><a href='/Kullanicilar/Details/" + item.ID + "'><img width='15' src='../../Content/images/Detay.png'></a></td><td><input id='Kisisec' value='" + item.ID + "' class='KisiSilici' type='image' width='20' src='../../content/images/sil.png' /></td></tr><hr />"; 
 
         }); 
 
         $("#Kisiler").html(row); 
 
        }, 
 
        error: function (result) { 
 
         alert("Error"); 
 
        } 
 

 
       }) 
 
      }); 
 
      $(function problem() { 
 
       $('.KisiSilici').click(function() { 
 
        var ip = ""; 
 
        $.ajax({ 
 
         url: '@Url.Action("KisilerSil", "tabs")', 
 
         type: "POST", 
 
         data: { data: ip }, 
 
         success: function (data) { 
 
          var row = "<p>" + data + "</p>"; 
 
          $("#CihazKontrol").prepend(row); 
 
         }, 
 
         error: function (result) { 
 
          alert("Error"); 
 

 
         }, 
 
        }) 
 
       }); 
 
      });

+1

** $(功能问题()**是什么意思? – 2014-11-01 13:24:30

+1

你能否明白你在问什么? – 2014-11-01 13:25:36

回答

0

没有与此代码几个问题:

  • $(document).ready(...)$(...)完全一样,所以在$(document).ready(...)内使用$(...)没有任何意义。你可以松动$(...)环绕。
  • 给予匿名函数的problem给我们一个错误。作为参数的函数都意味着是匿名的,或只是引用(地名)到另一个功能,所以你可以做这样的:

    $(function() { 
        //do smth 
    }); 
    

或本:

function do(){ 
     //do smth 
    } 
    $(do); 

所以,你的代码,因为我看到它,应该看起来更像这样:(在这里很难说出你的观点)

 $(document).ready(function Kisilertabs() { 
      $("#tabs").tabs(); 
      var id = @Model.ID.ToString() 
      $.ajax({ 
       url: '@Url.Action("Kisiler", "Cihazlar")', 
       type: "get", 
       contentType: "application/json; charset=utf-8", 
       data: { data: id }, 
       dataType: "json", 
       success: function (data) { 
        var row = "<tr><th width='70'>S. No</th><th width='220'> Adı </th><th width='220'>Soyadı</th><th>Sicil No</th><hr/></tr>"; 
        $.each(data, function (index, item) { 
         row += "<tr id='" + item.ID + "'><td>" + item.ID + "</td ><td>" + item.Adi + "</td><td>" + item.Soyadi + "</td><td>" + item.Sicil + "</td><td><a href='/Kullanicilar/Details/" + item.ID + "'><img width='15' src='../../Content/images/Detay.png'></a></td><td><input id='Kisisec' value='" + item.ID + "' class='KisiSilici' type='image' width='20' src='../../content/images/sil.png' /></td></tr><hr />"; 
        }); 
        $("#Kisiler").html(row); 
       }, 
       error: function (result) { 
        alert("Error"); 
       } 

      }) 
     }); 

     $('.KisiSilici').click(function() { 
      var ip = ""; 
      $.ajax({ 
       url: '@Url.Action("KisilerSil", "tabs")', 
       type: "POST", 
       data: { data: ip }, 
       success: function (data) { 
        var row = "<p>" + data + "</p>"; 
        $("#CihazKontrol").prepend(row); 
       }, 
       error: function (result) { 
        alert("Error"); 
       }, 
      }); 
     });