gpt4 book ai didi

javascript - 没有类型的cshtml脚本标签

转载 作者:行者123 更新时间:2023-12-03 12:02:34 26 4
gpt4 key购买 nike

我对 ASP.NET 和前端技术总体来说是新手。我有以下代码:

<ul>
@foreach (var item in Model)
{
<li>
<img src="@item" alt="file here" width="100" height="100" />
<a id="@item" href="#" onclick="deleteFile('@item');">Delete</a>
</li>
}
</ul>

<script>
function deleteFile(item) {
var url = "/Home/DeleteFile";
$.post(url, { Name: item }, function (data) {
window.location.href = "/Home/Upload";
});
}
</script>

我知道我们可以通过类型标签识别编写脚本所用的语言。例如

<script type="text/javascript"...

但是如果不指定这个类型,我如何识别脚本的语言呢?此外,在脚本中,post 语句中的参数“function(data)”是做什么的,该函数的数据参数来自哪里?

谢谢!

最佳答案

参见the HTML specification :

The type attribute gives the language of the script or format of the data. If the attribute is present, its value must be a valid MIME type. The charset parameter must not be specified. The default, which is used if the attribute is absent, is "text/javascript".

关于javascript - 没有类型的cshtml脚本标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25346745/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com