.JS File using @url.action in Ajax Url

后端 未结 3 1234
粉色の甜心
粉色の甜心 2020-12-04 03:45

I been trying to use @Url.Action inside Ajax url in another external .JS file but unfortunately i got no luck.

Here\'s my Cod

3条回答
  •  悲哀的现实
    2020-12-04 04:07

    if your js code inside view

    $.ajax({
          type: 'post',
          url: "@Url.Action("ClearData","Home")",
          success: function () {
    
           }
         });
    

    this is work

    when js code is an separate (external file) @Url.Action("ClearData","Home") is not work , this case you have to write total url or folder path

提交回复
热议问题