2011-04-26 122 views
0

基本上,我想通過ajax在外部Js文件中使用php variavle。例如:如何在ajax的外部JavaScript文件中使用php變量?

在使用example.php文件

<?php 
$a="123" 
//and then I want to call a show() function through a onclick event later 
<xxxxxxxxxxxxx...... onclick="show()">; 
?> 
在另一個example2.js

文件中,有一個功能

show() 
{ 
    var b 
    // I want to assign $a's value to this variable b here.=> b=a 

    //but I only want to do this way by using ajax. 

} 

有沒有人能告訴我該怎麼做?謝謝。

回答

0

您是否嘗試將ajax_object.responceText插入到a中的值中,然後使用javascript獲取它?

相關問題