Javascript 敲除-如何从select中获取值并将其传递给ajax调用

Javascript 敲除-如何从select中获取值并将其传递给ajax调用,javascript,jquery,html,ajax,knockout.js,Javascript,Jquery,Html,Ajax,Knockout.js,如何获得敲除中可观察属性的值?作为JSFIDLE中的一个示例,如何获得percentBonus的值并在组合框更改时使用它 另外,当我更改state的值时,如何使city的组合框更改 在实际场景中,会有州,城市会根据所选州的不同而变化。我将通过对select you need observable not observable数组进行ajax调用,从服务器获取城市列表 self.selectedCity = ko.observable(); self.selectedCity.subscribe(

如何获得敲除中可观察属性的值?作为JSFIDLE中的一个示例,如何获得percentBonus的值并在组合框更改时使用它

另外,当我更改state的值时,如何使city的组合框更改


在实际场景中,会有州,城市会根据所选州的不同而变化。我将通过对select you need observable not observable数组进行ajax调用,从服务器获取城市列表

self.selectedCity = ko.observable();
self.selectedCity.subscribe(function () {
    alert("this is percentage" + self.percentBonus());
})
这是

对于组合框,可以调用change event

<select id="stateSelect" style="background-color:#69bed2; width:50px;" data-placeholder="..." 
data-bind="
        options: stateValue, 
        selectedOptions: selectedStates,
        event:{change:$root.ChangeCity}"
name="state" class="chosen-select" tabindex="1"></select>
<select id="stateSelect" style="background-color:#69bed2; width:50px;" data-placeholder="..." 
data-bind="
        options: stateValue, 
        selectedOptions: selectedStates,
        event:{change:$root.ChangeCity}"
name="state" class="chosen-select" tabindex="1"></select>
self.cityValue = ko.observableArray();
self.ChangeCity = function(state){
    $.ajax({
        data: {state : state}
        .
        .
        .
        success : function(array){
            self.cityValue(array)
        }

    })
}