jqueryを使用してajaxからデータが取得されているページのデータをクロールするにはどうすればよいですか?C#コンソールで実行したいです。
1 に答える
Well, it depends on the structure you use to post your data.
$.ajax({
type: "POST",
url: "path.to.my.net.page",
data: (my.data),
error: function(xhr,status,error) {/* what to do if something is wrong */},
success: function(return.data) {/* what to do if everything is all right */}
});
The previuos snippet is a classical AJAX call via jQuery. The "my.data" structure will be processed by "my.net.page". The data will be accessible as it was a normal post variable in your .NET code, but depending on the structure, it must be processed in different ways.
The data may be a simple comma separeted string (boooh), or a well formed JSON structure. JSON lets you shape your data as a serialized object that you can deserialize and access in your csharp page. There are a lot of library. I suggest you JSON.NET. Have a try here with this sample:
{"id" : "0023", "name" : "Zap", items : [{"itemId" : "1", itemValue : "One"}, {"itemId": "2", "itemValue" : "Two"}]}