2013-02-11 114 views
1

我正在使用jQuery方法开发Country,State,City,但是问题是当load事件触发,也改变()被触发,并且我无法加载状态下拉关于加载事件,选择更改事件触发,jQuery

$("#SelectCountry").load() { 
    $.ajax({ 
     url: "../Member/Home.aspx/GetCountryName", 
     type: "POST", 
     dataType: 'json', 
     contentType: 'application/json; charset=utf-8', 
     data: "{'name': '" + "1" + "'}", 
     async: false, 
     success: function (response) { 
      if (response.d != null) { 
       $.each(response.d, function (i, response) { 
        debugger; 
        $("#SelectCountry").append("<option value=" + response.CountryId + ">" + response.CountryName + "</option>"); 
       }); 
      } 
     }, 
     error: function (xhr) {} 
    }); 
} 
$("#SelectCountry").change() { 
    alert("Select event changed;"); 
} 
+0

如果你的代码格式正确,好的东西就会发生在你身上! :) – Trufa 2013-02-11 16:07:40

回答

1

你应该

$("#SelectCountry").load(function() { // pass a callback to load 
    ... // will be executed when loading finishes 
}); 

但在更换

$("#SelectCountry").load() { // doesn't compile 
    ... 
} 

你的情况,即使我没有看到HTML,我不明白你为什么要使用加载。你应该简单地调用块内的代码。

+0

你的小提琴不导入jquery,并没有html ... – 2013-02-11 16:35:32

+0

我只是想显示一个脚本!,我打算发布在pastebin上,谢谢你的回复 – 2013-02-11 16:39:50

+0

好的,写这个我能够激发我的webmethod :http://pastebin.com/CpFDQQwF – 2013-02-11 16:41:18