我有JS脚本从后端获取数据
这是脚本
<script>
$(document).ready(function() {
emaillist_update();
});
function emaillist_update() {
var url = window.location.pathname;
var id = url.substring(url.lastIndexOf('/') + 1);
alert(id);
$.ajax({
url: '@Url.Action("Displayinfo", "Questions")',
type: 'Post',
dataType: 'Json',
data: {
ID: id
}
success: function(result) {
var info = result;
$("#vacancy").append("Мы ищем специалиста на вакансию:" + info.Vacancy);
},
error: function(result) {
alert('Error');
}
});
}
这是后端的代码
public ActionResult Displayinfo(int ID)
{
var res = db.Interview
.Where(x => x.Interview_Id == ID)
.Select(x => new
{
Vacancy = x.Vacancy.VacancyName,
Greeting = x.Greeting,
Detail = x.Detail
}).FirstOrDefault();
return Json(res, JsonRequestBehavior.AllowGet);
}
我在此行Uncaught SyntaxError: Unexpected identifier
url: '@Url.Action("Displayinfo", "Questions")',
什么是麻烦?网址似乎是正确的
感谢您的帮助