我有一个非常简单的观点。它包含一些 C# 代码。
@{
ViewBag.Title = "Community";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div id="req1">
<form>
<input id="txt1" type="text" name="txt1" />
</form>
</div>
<div id="btn1">Send</div>
<div id="res1"></div>
@{
public string GetPassage(string strSearch)
{
using (var c = new System.Net.WebClient())
{
string url = "http://www.esvapi.org/v2/rest/passageQuery?key=IP&passage=' + strSearch + '&options=include-passage-references=true";
return c.DownloadString(Server.UrlDecode(url));
}
}
}
我不知道出了什么问题。错误信息是:
Source Error:
Line 117:EndContext("~/Views/Home/Community.cshtml", 236, 9, true);
更新:
如果我将代码移至控制器。
public ActionResult Community()
{
ViewBag.Message = "";
return View();
}
public string GetPassage(string strSearch)
{
using (var c = new System.Net.WebClient())
{
string url = "http://www.esvapi.org/v2/rest/passageQuery?key=IP&passage=" + strSearch + "&options=include-passage-references=true";
return c.DownloadString(Server.UrlDecode(url));
}
}
我想根据示例进行 ajax 调用。javascript中的代码如何?