嘿所有我一直在寻找一段时间,并没有太多运气找到这背后的原因,所以希望有人可以帮助我。我不明白为什么它返回换行符
$('#tbl tr td').click(function () {
// Here selection =" 710-610A " spaces are included
var selection = $(this).text();
alert(selection)
$.ajax({
type: "Post",
url: "/Home/Index/",
dataType: "json",
data: { grpCode: selection },
success: function (ResponseData) {},
error: function (errorResponse) {
alert('AJAX Call Failed');
}
// When passed grpCode = "\n 710-610A\n "
I dnt understand why theres so many spaces along with it
[HttpPost]
public ActionResult Index(string grpCode)
{
// do something
}
我认为这与我在视图中显示表格的方式有关
<table id="tbl">
<tr>
<th>
Groups
</th>
</tr>
@foreach (var item in Model.groupCodesList.Select(m=> m.Group_Code).Distinct())
{
<tr>
<td>
@item
</td>
</tr>
}
</table>
我正在使用 EF Code First 来检索数据