Reputation: 398
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?
Upvotes: 0
Views: 487
Reputation: 887837
Call $.getScript(someUrl)
to add a <script>
tag that calls your action.
Upvotes: 2