I have ajax code for asp.net (non-mvc) to call to a webMethod to get additional data from the server for a request. But I can’t seem to figure out the url to give my JQuery in MVC.
<script type="text/javascript" language="javascript">
function SubmitAjax(url, message, successFunc, errorFunc) {
$.ajax({
type:"POST",
url:url,
data:message,
contentType: "application/json; charset=utf-8",
dataType: "json",
success:successFunc,
error:errorFunc
});
};
I don’t want to pass the entire list of related data to a select list to every person that arrives at the page, as not all will need this functionality. So I’d like to call a controller or webmethod via JQuery, but can’t seem to find out how to address the URL in MVC.
I noticed this post:
JQuery Ajax call gets resolved to the current Controller Folder, Instead of root Folder
is $.getJson an mvc method? is this a good solution for my use case? I only need to return a string url, or an empty string if what i’m looking for is not found. Do I need to include a for the $.getJSon method? is that part of MVC or part of JQuery? Is the leading slash going to point to Application root or server root?
The problem was the webMethod Tag on the controller, that was needed or helpful in asp.net, but not in asp.net mvc