Php 如何从asp.net-mvc控制器操作返回原始数组
我是(multiple Bird(remote)示例),但是后端示例是php,我的后端是asp.net-mvc。我正在尝试将这段php代码翻译成asp.net-mvc。是否可以仅从asp.net-mvc控制器操作返回数组(而不是使用Json或XML)Php 如何从asp.net-mvc控制器操作返回原始数组,php,jquery,asp.net-mvc,Php,Jquery,Asp.net Mvc,我是(multiple Bird(remote)示例),但是后端示例是php,我的后端是asp.net-mvc。我正在尝试将这段php代码翻译成asp.net-mvc。是否可以仅从asp.net-mvc控制器操作返回数组(而不是使用Json或XML) 您可以使用以下选项: public ActionResult Search(string q) { // fetch those from the database var values = new[] { "value1", "v
您可以使用以下选项:
public ActionResult Search(string q)
{
// fetch those from the database
var values = new[] { "value1", "value2", "value3" };
// filter based on the search string the user entered
var result = values.Where(x => x.Contains(q));
// render them to the response
return Content(string.Join("\n", result), "text/plain");
}
在你看来:
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.autocomplete.js")" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#items').autocomplete('@Url.Action("search")');
});
</script>
<input type="text" id="items" name="items" />
$(函数(){
$('#items').autocomplete('@Url.Action(“search”));
});
我正试图在一个ajax调用的支持下实现这一点。。php是如何工作的呢???@ooo,结果直接写入response.Darin,如果要求以原始顺序呈现键/值对(其排序标准未知),您将使用哪个集合?字典不保留插入顺序,对吗?而分类列表也帮不上忙。思想?Serge-appTranslator,或者简单地使用所需的顺序对控制器操作中的元素重新排序。
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.autocomplete.js")" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#items').autocomplete('@Url.Action("search")');
});
</script>
<input type="text" id="items" name="items" />