0
我通過Ajax
這樣的電話獲得數據列表。ajax獲得使用asp.net後發佈數據ajax
$(document).ready(function() {
var hashtag = 'dilwale'
var accessToken = '16741082.1b07669.121a338d0cbe4ff6a5e04543158a4f82'
$.ajax({
url: 'https://api.instagram.com/v1/tags/' + hashtag + '/media/recent?count=33&access_token='+ accessToken +'',
dataType: 'jsonp',
type: 'GET',
success: function (data) {
//Here I want to post data in database through ajax call Instead of showing
for (x in data.data) {
if (data.data[x].type == 'video') {
$('.instagram').append('<div style="border:1px solid orange"><video controls><source src="' + data.data[x].videos.standard_resolution.url + '" type="video/mp4"></video><span style="border:1px solid orange; dislay:block">Test1</span></div>');
} else if (data.data[x].type == 'image') {
$('.instagram').append('<div style="border:1px solid orange"><img src="' + data.data[x].images.standard_resolution.url + '" ><span style="border:1px solid orange; display:block">"' + data.data[x].caption.text + '"</span><span style="border:1px solid orange; dislay:block">Test1</span></div>');
}
}
},
error: function (data) {
}
})
});
將數據插入功能如下
function InsertData() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default.aspx/SaveData",
data: {},
dataType: "json",
success: function (data) {
// Show data after success
},
error: function() {
alert("Error while Showing update data");
}
});
}
在這裏,我要保存數據的列表。 我WEBMETHOD保存數據如下
[WebMethod]
public static void SaveData(Document objDocs) //I have taken a class Document
{
//Saving data in database
}
我不能讓它正確地保存數據獲得後,然後在頁面上顯示。