私の大学の成績表 (結果) は非常に複雑で、実際の学生の割合を計算するのは非常に困難です。そこで、学生が登録番号を入力するだけでよいサービスを学生に提供したいと考えています。そして結果は自分で計算します。
最初に、 http://hurl.itの成績表ページにポスト リクエストを送信しようとしまし た。パーマ リンクは次のとおりです。
しかし、私のウェブサイトから jquery を使用して同じリクエストを送信すると、エラーが発生します。次のコードを使用してリクエストを送信しています。
$.ajax({
type: "POST",
url: "http://stusupport12.ignou.ac.in/Result.asp",
data: "submit=Submit&eno=092853268&hidden%5Fsubmit=OK&Program=BCA",
success: function (d) {
$("#resultDiv").html(d);
},
error: function (a, b, c) { alert(a + b + c); }
});
友達を助けてください。
更新 2 - サーバーでリクエストを処理してソリューションを見つけました。サーバーで要求を処理し、処理された要求をクライアントに送り返す汎用ハンドラー (.ashx) を作成しました。Jqueryで呼び出すことができます。
ここにコードがあります
<%@ WebHandler Language="C#" Class="IGNOU" %>
using System;
using System.Web;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Net;
using System.IO;
public class IGNOU : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/html";
context.Response.Write(Func(context.Request.QueryString["eno"]));
}
public bool IsReusable {
get {
return false;
}
}
public string Func(string eno)
{
string str = string.Empty;
WebRequest request = WebRequest.Create("http://stusupport12.ignou.ac.in/Result.asp");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "submit=Submit&Program=BCA&hidden_submit=OK&eno=" + eno;
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
// Clean up the streams.
reader.Close();
dataStream.Close();
response.Close();
return responseFromServer;
}
}
更新 1 Web ページへのリンクを追加 https://www.bobdn.com/IGNOU_BCA_Result.aspx