0

load() 関数を使用して、メインの php ページの div 内に search_result.php ファイルをロードしたいと考えています。私はjsonコードを解析する関数を書きました

json_parsing(document.getElementById('start_val').value, <?php echo $jsoncode;?>);

今、次のコードを使用して search_result.php ファイルをロードするときに必要です

$("#search_result_cont").load("search_result.php");

内部の関数は、現在の Web ページ要素 #start_value と php 変数 $jsoncode から値を取得します。

そうすることは可能ですか?

4

1 に答える 1

0
$.get( 'search_result.php'.function(text){
     eval(text); // text is without the script tags
},'text');

また

$.get( 'search_result.php'.function(json_text){
     json_parsing(document.getElementById('start_val').value, json_text); 
     // json_text is just $jsoncode
},'text');

また、 $.parseJSON(text) と $.getJSON(); を使用できるのに、なぜ自分でjsonを解析するのですか? 通常、このような問題は、適切なプログラミング設計ではない方法で何かを行おうとしていることを示しています。

于 2012-09-22T15:15:09.260 に答える