How to get the this??? pointed by a function other than a function in javascript

like the following code,
how do I get the ("- sharpadd_img2") outside ajax () inside ajax (). Change () points to this???
ajax () inside console.log (this). The this output here points to ajax,
how do I make the this of this output point to ("- sharpadd_img2"). Change ()?

$("- sharpadd_img2") .change (function () {
console.log (this)

// , ajax 
var formdata=new FormData();
var add_img2=this.files[0];
 formdata.append("uploadImage",add_img2);
    var str="1111";
    formdata.append("recid",str);
    var title="";
    formdata.append("title",str);
    
    $.ajax({
        url:"/imageText/saveImage.do",
        type:"post",
        contentType:false,
        data:formdata,
       // data:{"title":title,"uploadImage":uploadImage},
        processData:false,
        success:function(info){
            console.log(info);
            // img
            this.siblings(".this_show_img").attr("src",info)
            console.log(this)
        },
        error:function(err){
            console.log(err);
        }
    });

})

Mar.29,2022

Arrow function or var that = this;
and your this > should $(this)


ajax the outer function sets a variable pointing to this
such as var self = this;
$.ajax. Just use this variable in


success: info => {console.log(this)}
.
Menu