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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With