0
$(document).ready(function() {
$('#dropDownMenu1').change(function() {
var customer = { contact_email: "[email protected]", company_password: "123" };
$.ajax({
type: "POST",
data: JSON.stringify(customer),
url: "webServices/apiDeneme.ashx",
contentType: "application/json"
});
});
});
我將此客戶變量像這樣發送到apiDeneme.ashx。我把調試poing,請求來到apiDeneme.ashx但這個電子郵件字符串變量等於空。 ? (下)使用Ajax應用程序/ json的POST數據,使用ashx文件讀取
public void ProcessRequest(HttpContext context)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
string email = context.Request.Form["contact_email"];
sb.Append("[");
sb.Append("{");
sb.Append("\"Sonuc\":\"" + email + "\"}]");
context.Response.ContentType = "application/json";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.Write(sb.ToString());
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
順便說一句,另一個問題,像這裏的登錄過程是可靠的嗎?謝謝!!
字符串電子郵件仍然是空,但我不能添加一個[HttpPost]。 Tt給出了語法錯誤。 (意味着:紅色下劃線)。當我輸入[HttpPost]時,爲什麼Visual Studio沒有「解析..」幫助解決此語法錯誤。因此,最後,電子郵件的值仍然爲空。這是否因爲[HttpPost]而爲空?如果是的話,我如何添加這個[HttpPost]沒有任何語法錯誤? – user3615345