The object is passed in the change method in Jquery, but it is only called once?

I want to assign a value to a drop-down box:

      <div class="input-control text full-size" data-role="input">
                            <select id="storageInfo" name="storageInfo">
                            </select>
                        </div>

Js:

 //change
                $("-sharppurchaseEmp").bind("change", function () {
                    /**
                     * 
                     */
                    $.ajax({
                        url: "/DemandPlan/Instock/SelectStorageWithEmp/",
                        dataType: "JSON",
                        data: {
                            sys_emp_id: $("-sharppurchaseEmp").val().split(",")[0]
                        },
                        type: "POST",
                        success: function (resp) {
                            if (resp.res != "Failure") {
                                $("-sharpstorageInfo").empty();
                                if (resp.res.length == 0) {
                                    $("-sharpstorageInfo").append("<option value="none">...</option>");
                                }
                                $(resp.res).each(function (i, c) {
                                    $("-sharpstorageInfo").append("<option value="" + c.wl_storage_id + "," + c.wl_storage_name + "">" + c.wl_storage_name + "</option>");
                                    // $("-sharpUpdateDeptInfo").append("<option value="" + c.sys_dept_id + "," + c.dept_name + "">" + c.dept_name + "</option>");
                                });
                                $("-sharpstorageInfo").select2();
                                // $("-sharpUpdateDeptInfo").select2();
                            } else {
                                console.log(resp.Msg)
                            }
                        }
                    });
                });

it"s okay to write this way, but I declare a method and pass it in,

write this way, the change event of the drop-down box will only be executed once, and then it will have no effect.
Please tell me why?

Mar.23,2021

should be:

$("-sharppurchaseEmp").change(function() {
    // 
    selectPurchaseEmp(...);
});

if selectPurchaseEmp has no parameters, it can be:

$("- sharppurchaseEmp") .change (selectPurchaseEmp);

The argument to

change () is a function

but the change (selectPurchaseEmp (.)) you passed is not selectPurchaseEmp this function , but the return value of selectPurchaseEmp (.)

.
Menu