OnSuccess()
内でメソッドを起動した要素のターゲットを取得できませんAjax.BeginForm()
。コードスニペットは次のとおりです。
@using (Ajax.BeginForm("InsertModel", "Home", new AjaxOptions
{
HttpMethod = "POST",
OnSuccess = "doWork(this,'SomeCustomText')"
}))
{
<div id="container">
<--Some HTML--!>
<input type="submit" value="OK"/>
</div>
}
<script>
function doWork(e,customText)
{
alert(customText); //It shows 'SomeCustomText', so its good.
alert(e); //[Object] object
alert(e.prop("tagName")); //Object #<Object> has no method 'prop'
alert(e.attr("tagName")); //Object #<Object> has no method 'attr'
alert(jQuery(e).html()); //undefined
alert(jQuery(e).prop("tagName")); //undefined
alert(e.target); //undefined
alert(jQuery(e).target); //undefined
}
<script/>
質問:
ターゲットの入手方法は!? ありがとうございました
更新 1
jQuery のバージョンは次のようになります。
jQuery.ajax({
url:"/Home/InsertModel",
data:"some post data",
type:"POST",
success:function(data){
doWork(this,data); // so i really do not care about data! I just need jQuery(this)
}
})