AJAX JQUERY RELATED:- How to call ajax on a ajax loaded page

后端 未结 3 1276
甜味超标
甜味超标 2021-01-27 03:09

Assume I\'m calling search through AJAX. Now I want to call another AJAX on the page that will be loaded by AJAX and can be edited.



        
3条回答
  •  庸人自扰
    2021-01-27 03:56

    Assuming that you have something basically like this structure and jQuery 1.7+

    data

    On the parent page, you need to attach "delegated handlers", which are event handlers placed on parent elements that execute for present or future child elements.

    And so, assuming that we have a container div id'ed "resultContainer" in which you dump the live data, we attach it handlers:

    //attach a delegated submit handler on resultContainer for forms
    $('#resultContainer').on('submit','form',function(event){
        //do what you want when an item is edited
        //"this" inside here is the DOM element form, which fired the submit
        //prevent the default submit action using event.preventDefault()
        //$(this).serialize() turns the form data into a serialized query string
    });
    

    提交回复
    热议问题