2016-04-21 25 views
0

我用語音XML來選擇標誌或電影。把logo.svgmovie.phptxt文件,然後我用PHP來加載logo.svgmovie.php$theData如何使用TXT內容的onclick =「doAjaxCall(」「)?

<?php 
ini_set("display_errors", true); 

// define your file name as a variable 
$myFile = "voice.txt"; 

// get a FILE HANDLE to the file: 'r' means set permission to read 
$fh = fopen($myFile, 'r'); 

//read the entire file and store the contents in the variable $theData 
$theData = fread($fh, filesize($myFile)); 

// close the file so it will be OK to use later 
fclose($fh); 

//echo whatever is in the file back to the browser 
echo $theData; 



// PART 2 
// get a FILE HANDLE to the file: 'a' means set permission to read 
$fh = fopen($myFile, 'w') or die("Error trying to open with a"); 

$noData = "no msgs"; 

//read the entire file and store the contents in the variable $theData 
$theData = fwrite($fh, $noData); 

// close the file so it will be OK to use later 
fclose($fh) 

?> 

現在我想告訴他們要麼對網 我使用:??

<input class="logo" type="button" value="Call (832) 271-6319 " onclick="doAjaxCall(' ');"/> 

我怎樣才能做到這一點我應該使用JavaScript

+0

我用這個在HTML <輸入類= 「標誌」 類型= 「按鈕」 值= 「調用(832)271-6319」 的onclick = 「doAjaxCall( 'movie.php');」/> – vivian

+0

我不明白你想達到什麼。 onclick允許你添加一個javascript函數。你可以用這個函數進行ajax調用。 –

回答

0

我不知道你想達到什麼。 的onclick允許你添加一個JavaScript函數一樣

<input onclick="myFunction()" /> 

你可以從這個函數調用Ajax。 或者你可以使用jQuery並附加一個函數來輸入點擊事件。

$(".logo").click(function(){ 
..... 
}); 
+0

謝謝你的回覆。我打電話說徽標,網頁上會顯示logo.svg。我該怎麼辦。 – vivian