我试图实现这个简单的例子http://www.aspsnippets.com/Articles/Call-ASPNet-Page-Method-using-jQuery-AJAX-Example.aspx
但它没有用,它给出了
import org.apache.spark.sql._
val rdd = df2.rdd.map { case Row(j: String) => j }
spark.read.json(rdd).show()
客户端
Failed to load http://site/path/path/pagename.aspx/GetCurrentTime resource: the server responded with a status of 500 (Internal Server Error)
服务器(.cs文件)
<script src="http://.../jquery-1.7.2.min.js" type="text/javascript"></script>
<script type = "text/javascript">
function ShowCurrentTime() {
$.ajax({
type: "POST",
url: "pagename.aspx/GetCurrentTime",
data: '{name: "' + $("#<%=txtUserName.ClientID%>")[0].value + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
</script>
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
<input id="btnGetTime" type="button" value="Show Current Time"
onclick = "ShowCurrentTime()" />
答案 0 :(得分:0)
ajax定义中没有这样的函数failure
。您需要将其重命名为error
。检查来源:jQuery.ajax()
P.S 我也建议你使用console.log
,而不是提醒。 console.log
您的name参数,以查看是否返回正确的值。检查JSON.stringify以创建数据。