Ajax (this) not working

后端 未结 2 965
清歌不尽
清歌不尽 2021-01-11 19:35

When attempting to access the \'.box\' class of the $container, using (this) inside of the ajax call doesn\'t work.

$container.on(
        \"click\",
               


        
2条回答
  •  我在风中等你
    2021-01-11 20:28

    Just add this to your $.ajax call...

    context: this,
    

    ...and it'll work.


    $.ajax({
        context: this, // <-- right here
        url:'scripts/php/fetchResultsData.php',
        data: {action:value},
        type: 'post',
        dataType: 'json',
        success: function(data) { // ...
    

提交回复
热议问题