当我启动项目时,我遇到了[object Object]问题。
我想访问数据库值,然后我想创建新标记。
ShareList.js
function ata() {
$.ajax({
type: "POST",
url: "Home.Master/ShareList",
contentType: "application/json;charset-utf-8",
success: function (result) {
var MyData = JSON.parse(result.d);
alert(MyData);
var i;
var data = MyData.Table;
alert(data);
var maindiv = document.getElementById("fh5co-board");
var sablon;
for (i = 0; i < data.length; i++) {
var divitem = document.createElement("div");
divitem.setAttribute("class", "item");
var divanimate = document.createElement("div");
divanimate.setAttribute("class", "animate - box");
var a = document.createElement("a");
a.setAttribute("class", "image-popup fh5co-board-img");
a.setAttribute("href", "#");
var img = document.createElement("img");
img.setAttribute("src",data[i].PATH);
a.appendChild(img);
var divText = document.createElement("div");
divText.setAttribute("class", "fh5co-desc");
var stringName = data[i].NAME;
divText.appendChild(stringName);
divanimate.appendChild(a);
divanimate.appendChild(divText);
divitem.appendChild(divanimate);
maindiv.appendChild(divitem);
}
},
error: function (hata) {
alert(hata);
}
});
}
$(document).ready(function () {
setInterval(ata, 1000);
});
Home.Master.cs 我想用OracleDataAdapter访问数据库这个页面。
public partial class Home : System.Web.UI.MasterPage
{
String connectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
OracleConnection cnn = null;
protected void Page_Load(object sender, EventArgs e)
{
}
public string ShareList()
{
cnn = new OracleConnection(connectionString);
OracleDataAdapter adp = new OracleDataAdapter("SELECT Q.NAME,Q.CREATEDATE,P.PATH FROM QUESTION Q INNER JOIN PHOTO P ON P.PATH=Q.PHOTOID",cnn);
DataSet ds = new DataSet();
adp.Fill(ds);
string data = JsonConvert.SerializeObject(ds, Formatting.Indented);
return data;
}
}