I can't get the the target of the element which fired OnSuccess()
method within Ajax.BeginForm()
. So here is the code snippet:
@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/>
The Question:
How to get target?! Thank you
Update 1
The jQuery version should look like this:
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)
}
})
data
. Here is an example:jQuery.ajax(){url:"/Home/Insert",type:"POST",success:function(data){ alert(data); // so i do not care about data! I just need jQuery(this); where this - I suppose it should be the form()}}
– LuxateOnSuccess()
"? – Masterpiecethis
, insideOnSuccess = "doWork(this,'SomeCustomText')"
– Luxate