Home Call Ajax.beginForm's onSuccess function from another script file
Reply: 0

Call Ajax.beginForm's onSuccess function from another script file

Si Mohamed
1#
Si Mohamed Published in 2017-09-13 09:34:15Z

so i'm still a beginner and I'd like to understand something. My page had the following:

@using (Ajax.BeginForm("ManageHistory", "History", new AjaxOptions()
{
HttpMethod = "POST",
OnSuccess = "onSuccess" @*, InsertionMode = InsertionMode.Replace, UpdateTargetId = "historyContainer"*@ }))
{
<script>
function onSuccess(data, status, xhr) {
        var ct = xhr.getResponseHeader("content-type") || "";
        if (ct.indexOf('html') > -1) {
            $("#historySheetSettingsContainer").html(data);
        }
        if (ct.indexOf('json') > -1) {
            console.log("oki");
        }
    }
</script>

I had a lot of js functions as well, but I decided to put them all away in a script file. All of them are working just fine except the onSuccess function thar I couldn't figure out how to call it from the cshtml file. I'd like to how, Thank you.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.417563 second(s) , Gzip On .

© 2016 Powered by cudou.com design MATCHINFO