javascript - Index doesn't appear in url as expected, so AJAX calls go towrong location - MVC Routing AJAX -
i have application if click on link (in /imageslist/index.cshtml) send me view in directory (/imagesanalysis/...). via controller function loads data.
the problem have expect have url /imageanalysis/index have /imageanalysis
imageslist controller
public actionresult view(int? id) { if (id == null) { return new httpstatuscoderesult(httpstatuscode.badrequest); } return redirecttoaction("open", "imagesanalysis", new { id = id }); }
imagesanalysis controller
public actionresult open(int id) { //load items db return redirecttoaction("index"); } public actionresult index() { if (session["img"] == null) { session["img"] = new imagemodel(); } return view((imagemodel)session["img"]); }
the problem ajax call go the wrong location
/imagesanalysis/index.cshtml
$("#imageaccordion").accordion({ collapsible: true, heightstyle: "content", activate: function (event, ui) { $.ajax({ type: "post", url: "setactiveimage", datatype: "json", traditional: true, data: { imagenumber: this.id, }, success: function (data) { drawing.src = "/images/" + data; } }); } });
when using firebug ajax call goes url /setactiveimage instead of /imagesanalysis/setactiveimage
use full url path.=>simple answer.
usually when situations occur, configuration issue.
Comments
Post a Comment