Warren Smith
Warren Smith

Reputation: 1

ASP.net Access Controller Variable in View

Ok, I have a controller that returns a response to an ajax call and I'd like to intercept that response in my view. How can I do this?

Alternatively, how could i reference my ajax variable in my view?

View: ContractorList.ascx Controller: HaulerController.cs

Upvotes: 0

Views: 385

Answers (1)

DaveDev
DaveDev

Reputation: 42185

Not sure exactly what you're asking, but I think the answer is something along the lines of this:

$.get("/url/to/action", {/* data you're passing to action */}, function (response) {

    // your result is available here.... 
    // you want to pass it into the callback method as an argument, as above
    // everything your action returns to the page is stored in the response object.

    // can you do something like:
        var idx = response.indexOf('specific string I expect');
        if (idx > -1)
            // the string you expected is there so show popup....

    }, "html");

    return false;
});

If this isn't what you're after, please clarify

Upvotes: 1

Related Questions