ファイル1:test.php
$(document).ready(function() {
$.post( "test2.php")
.done(function( data ) {
alert(data);
});
});
または var var1="something"; $(document).ready(function() {
$.post( "test2.php",{demo:var1}) .done(function( data ) { alert(data); }); });
ファイル2:test2.php
<?php $sql="SELECT * FROM xyz";
$resultset=$database->query($sql);
$found=$database->mysql_fetch_array($resultset);
print_r($found); ?>
また
` $xyz=$_POST['demo'];
<?php $sql="SELECT * FROM $xyz";
$resultset=$database->query($sql);
$found=$database->mysql_fetch_array($resultset);
print_r($found); ?>`
SO、私のtest1.php は、そのような
もの、またはtest2.phpにあるhtmlコードのようalert(data);
ないくつかのprint_r配列を含むポップアップを警告し、それをフェッチして表示しますArray(
[0]=>1
[name_id]=1
)
私の問題は1)jsonまたはxmlでデータを取得する方法、またはこのデータを効率的に解析する方法ですか?2) 私の test2.php コンテンツが多くのクエリの場合、特定の ajax $.post 呼び出しの特定のデータを取得するにはどうすればよいですか?
親切にいくつかの本当の答えを提案してください!!