我在網站上獲得了一個腳本,每次按下按鈕時都會從文本文件中讀取html。文本文件的選擇取決於頁面的名稱。它可以正常工作並帶有標籤,並且可以用作其中的按鈕。Html表單按鈕功能單按鈕
我的問題是,我不希望和標籤在所有如果我想只有一個按鈕,我試圖打電話以各種方式與jQuery腳本和Ajax沒有任何的運氣。
繼承人的網站(其真正用於測試目的基本):
<html>
<head>
<title>PHP Flat File Test</title>
</head>
<body>
<?php include("savedinfo.php"); ?>
// This is how it works, its fine for multiple buttons in a row
<form method="get">
<button type="submit" name="page" value="index" action="savedinfo.php">Index</button>
<button type="submit" name="page" value="page1" action="savedinfo.php">Page1</button>
<button type="submit" name="page" value="page2" action="savedinfo.php">Page2</button>
</form>
//But this is the way I'd like to create a button(not exact properties but in one line)
<input id="pageBtn" type="button" page="page1" value="page1" />
</body>
它所做無需重新加載頁面只更新來自不同的文本文件的HTML網頁的區域。
加載HTML中的腳本:
<?php
//the script gets a name for a file(page) to load
$page = $_GET["page"];
//if it got no parameters(i.e. first load of the page, goto index)
if($page == null){
$page = "index";
}
//check if the file/page exists, othervise display error page
if(file_exists($page.".txt"))
$filename = $page.".txt";
else
$filename = "404.txt";
$f = fopen($filename,"rt");
$content = fread($f, filesize($filename));
// send back the read html
echo $content;
@fclose($f);
?>
的文本文件,網頁只是一個簡單的標籤,並從頁不同的一些文本。
現在是它甚至可以使用腳本或東西擺脫的標籤,如果你想創建一個按鈕,名稱的數據發送到腳本,並用新的信息更新當前頁?
顯示您在使用jQuery和Ajax因爲這是你說的是你的問題 –
減少你的代碼到你用,我們不會建立一個網站,你有問題的代碼的嘗試。 –
如果它可以幫助嘛代碼主要是爲了展示一下我想要實現的,這個問題是擺脫