Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Ajax URL Mappin issue on IIS

I'm Working on MVC application where I use Javascript to call server action methods. while working on local project I give URL as string with the following format "/ActionMethod/Controller". following is the code of my javascript ajax call. (Insert task is a action method in order controller.)

$.ajax({
  url: 'InsertTask/Order',
  type: "POST",
  data: {
    task: $("#taskMessagebox").val(), 
    orderId:$("#taskTable").attr("data-    orderId"),
    queueId: $("#taskTable").attr("data-queueId") 
  },
  success: function (data) {
    alert("success");
  }
},

Here is the controller action method :

public controller Order
{
  public actionResult InsertTask(int taskID)
  {
     // Implementation.
  }
}

Now when I published the code on IIS and then tried to run the application. It gives the URL not found error. I have published file in MVCApp folder. So default URL goes //Romanch/MVCApp.

like image 265
romie99 Avatar asked Feb 21 '26 17:02

romie99


1 Answers

Have you tried to use Url.Action(YOUR_PARAMS_HERE) inside i.e. buttons data-url attribute? Something like:

<input type="submit" data-url="@Url.Action(params)" Value="Insert" id="btnInsert" />

Then you can get this url from within you javascript

like image 128
vhr Avatar answered Feb 23 '26 05:02

vhr