开发者

What jQuery event type is it when Ajax inserts data into an input field?

开发者 https://www.devze.com 2022-12-21 18:45 出处:网络
I have an input field where the user enters an id#. I am using Ajax to check the database for that user\'s id# and afterwards populate the other input fields with that person\'s information from the d

I have an input field where the user enters an id#. I am using Ajax to check the database for that user's id# and afterwards populate the other input fields with that person's information from the database.

I am trying to run a series of validation statements after the information is inserted via Ajax into the input field开发者_StackOverflows, but I can't figure out which event I need to use.

I am trying to do something like this:

$(.formfields).dataInserted(function() {
    if(costCenter == '') {
        $("#cost_center").after('<div id="cost_center_error" class="error">Your cost center number is required.</div>');
        hasError = true;
    }
}

I can't use keyup or change or anything like that, since there the user doesn't actually manually enter the data. What jQuery event type is it when Ajax inserts data into an input field?


What jQuery event type is it when Ajax inserts data into an input field?

No event. Changing content from script does not fire any events(*). You must wire up your scripts to call you back when they've made a change.

If you really can't do that, you will need a poller interval to continually check the input for updates.

*: mostly. There are browser-specific hooks that you can use in some situations, but it's unpleasant and almost certainly better to fix the scripts to call you back instead. See this question for some discussion.

0

精彩评论

暂无评论...
验证码 换一张
取 消