読んでくれてありがとう。なめているように見える難問があります。JSON オブジェクトに基づいてテーブル行を作成する jQuery プラグインを作成しました。このプラグインでは、異なるキー/値のペアを持つ同じ変数名を持つ新しい JSON オブジェクトになる AJAX 呼び出しを持つページネーションが必要です (上書きしたい)。成功すると、データに警告できますが、警告しているデータの変数にアクセスできません。
var grid = {
"name": "test",
"columns":
[
{"name":"col1"},
{"name":"col2"}
],
"rows":
[
{"name":"col1", "value":"text1"},
{"name":"col2", "value":"text2"}
]
}
$("#myDiv").makeTable(); <-- plugin that creates table based off this JSON
// if I alert grid.columns[0].name I get col1 no problem.
次に、ループしてテーブルを作成するためにいくつかのjQueryを実行しますが、問題ありません...
次に、makeTable() プラグイン内から次のコード ブロックを取得します。
$.ajax({
url: 'get_json-pages.php',
type: "GET",
data: form_data, <-- my string
dataType:"script", <-- set it to script because the output is just the javascript
success: function(data) {
alert(data); <-- alerts perfectly, looks like the same JSON above but
with different key/value pairs
the alert looks like this:
var grid = {
"name": "test",
"columns":
[
{"name":"col3"},
{"name":"col4"}
],
"rows":
[
{"name":"col3", "value":"text3"},
{"name":"col4", "value":"text4"}
]
}
now when I do this:
alert(grid.columns[0].name);
it is a blank alert?
}
});
JSON オブジェクトを AJAX JSON で上書きし、プラグインをリロードして新しいデータ セットを表示するにはどうすればよいですか?
前もって感謝します!