第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

怎樣在jquery.ajax中執(zhí)行當(dāng)前函數(shù)的其他方法?

怎樣在jquery.ajax中執(zhí)行當(dāng)前函數(shù)的其他方法?

慕運(yùn)維8079593 2019-03-29 22:09:18
//簡(jiǎn)單的ajax表單提交(function($,window,undefined){varajaxForm=function(opts){vardef={successLabel:'發(fā)送成功',url:'/user/check',dataType:'html'}this.form=$('#'+formid)||$('form');this.opts=$.extend({},def,opts);this.formdata=this.form.serialize();}//發(fā)送前執(zhí)行ajaxForm.prototype.before=function(){this.submitButton=$form.find(':submit');this.submitButton.val('提交中...');}//請(qǐng)求成功回執(zhí)函數(shù)ajaxForm.prototype.success=function(data){$('#message')=this.opts.successLabel;}//ajaxForm.prototype.send=function(){$.ajax({url:this.opts.url,//無錯(cuò)before:this.before,//引用ajaxForm.before方法success:this.success,//執(zhí)行到這里錯(cuò)誤,success內(nèi)部this方法出錯(cuò)了type:'post',data:this.formdata})}window.ajaxForm=ajaxForm;})(jQuery,window)//實(shí)例newajaxForm().send();以上執(zhí)行,會(huì)提示this.opts.successLabel未定義,我知道當(dāng)ajax引用this.success的時(shí)候,success內(nèi)部this已經(jīng)指向當(dāng)前ajax對(duì)象了,請(qǐng)問各位老師,如何在ajax方法中,正確引用一個(gè)原型的方法呢?
查看完整描述

2 回答

?
慕尼黑5688855

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超2個(gè)贊

找到方法了,謝謝關(guān)注!
var_this=this;
$.ajax({
type:this.opts.method,
url:this.opts.url,
dataType:this.opts.data_type,
data:postdata,
success:function(){
_this.success.apply(_this,arguments);
},
error:function(){
_this.error.apply(_this,arguments);
}
});
                            
查看完整回答
反對(duì) 回復(fù) 2019-03-29
  • 2 回答
  • 0 關(guān)注
  • 360 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)