Passing a URL through jQuery with awkward routing
I am familiar with how to pass data through a url through jQuery, to my
ASP.NET MVC controllers, but I was writing some code today and came upon
an interesting URL that I cannot quite figure out how to format...
The route reads something like this ...
///////////////////////////////////////////
// route: /member/{0}/characters
///////////////////////////////////////////
public ActionResult Characters(int member){
// get the list of the member's characters
}
So the URL would actually have the 'parameter' right in the middle. This
is curious to me, because I'm not sure how this translates to the jQuery
"data" property on $.ajax. I would normally set it like this ....
$.ajax({
url: '/member/characters',
dataType: 'json',
data: { member: 1 }
}).done(function (data) { viewModel.set("Player", data); });
But that can't seem to work in this situation. I suppose I could do some
very hokey string formatting, but I am hoping to do this a bit more
cleanly...
Does anyone have suggestions for handling odd routes like this?
No comments:
Post a Comment