0

I want to execute Java Script generated from an MVC action method, I read that JavaScriptResult type can be used for that porpouse, but my question is if it can be called from jQuery.

Controller:

public JavaScriptResult myActionMethods() {

     return JavaScript("alert('" + DateTime.Now.ToString() + "');");
}

JavaScript file:

function CallActionMethodScript() {
     //I want to execute the resulting script using jQuery...
 }

Any idea?

1 Answer 1

2

Call $.getScript(someUrl) to add a <script> tag that calls your action.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.