我无法获得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)
}
})