我有一个基本的搜索页面,当我在文本框中输入一些单词时,已创建的记录显示在文本框的底部。每条记录都有如下链接:
www.blabla.com/record.php/record_id=9
。因此,在记录页面中,我获得记录ID,并显示记录信息。在同一页面中,当我点击按钮我需要在jquery上做一些工作,但我不能,因为当我点击和jquery工作时,链接返回www.blabla.com/record.php
和$_GET["record_id"]
给出错误。我需要使用get方法,所以我应该解决我怎么能保持record_id或者当我点击按钮时怎么能不丢失record_id?
(我实际上尝试了一些会话解决方案,但我无法得到它)
page:record.php / record_id = 9
$(document).ready(function() {
$(".ekle").each(function() {
$(this).click(function(event) {
$("#formnot").append('<input type="text" />');
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<form action="" method="" id="formnot">
<td></td>
<td>
<button type="submit" class="btn btn-primary btn-sm ekle" value="<?php echo $dosya_id; ?>">Yeni Not Ekle</button>
</td>
</form>
页:search.js
$(document).ready(function() {
// Icon Click Focus
$('div.icon').click(function(){
$('input#search').focus();
});
// Live Search
// On Search Submit and Get Results
function search() {
var query_value = $('input#search').val();
$('b#search-string').text(query_value);
if(query_value !== ''){
$.ajax({
type: "POST",
url: "search.php",
data: { query: query_value },
cache: false,
success: function(html){
$("ul#results").html(html);
}
});
}return false;
}
$("input#search").live("keyup", function(e) {
// Set Timeout
clearTimeout($.data(this, 'timer'));
// Set Search String
var search_string = $(this).val();
// Do Search
if (search_string == '') {
$("ul#results").fadeOut();
$('h4#results-text').fadeOut();
}else{
$("ul#results").fadeIn();
$('h4#results-text').fadeIn();
$(this).data('timer', setTimeout(search, 100));
};
});
});
页:search.php中
$html = '';
$html .= '<li class="result">';
$html .= '<a href="urlString">';
$html .= '<h3>nameString</h3>';
$html .= '<h4>functionString</h4>';
$html .= '<h4>displayMail</h4>';
$html .= '<h4>displayTc</h4>';
$html .= '<h4>display_durum</h4>';
$html .= '</a>';
$html .= '</li>';
// Get Search
$search_string = preg_replace("/[^A-Za-z0-9]/", " ", $_POST['query']);
$search_string = $tutorial_db->real_escape_string($search_string);
// Check Length More Than One Character
if (strlen($search_string) >= 1 && $search_string !== ' ') {
// Build Query
$query = 'SELECT * FROM musteri WHERE musteri_adi LIKE "%'.$search_string.'%" OR musteri_telefon LIKE "%'.$search_string.'%" OR musteri_mail LIKE "%'.$search_string.'%"
OR musteri_tcno LIKE "%'.$search_string.'%" OR musteri_pasaport LIKE "%'.$search_string.'%" ';
// Do Search
$result = $tutorial_db->query($query);
while($results = $result->fetch_array()) {
$result_array[] = $results;
}
// Check If We Have Results
if (isset($result_array)) {
foreach ($result_array as $result) {
// Format Output Strings And Hightlight Matches
$display_name = preg_replace("/".$search_string."/i", "<b class='highlight'>".$search_string."</b>", $result['musteri_adi']);
$display_function = preg_replace("/".$search_string."/i", "<b class='highlight'>".$search_string."</b>",$result['musteri_telefon']) ;
$display_url = 'record.php?record_id='.urlencode($result['record_id']);
$display_mail = preg_replace("/".$search_string."/i", "<b class='highlight'>".$search_string."</b>", $result['musteri_mail']);
$display_tcno = preg_replace("/".$search_string."/i", "<b class='highlight'>".$search_string."</b>", $result['musteri_tcno']);
$display_durum = preg_replace("/".$search_string."/i", "<b class='highlight'>".$search_string."</b>", $result['musteri_durum']);
// Insert Name
$output = str_replace('nameString', $display_name, $html);
// Insert Function
$output = str_replace('functionString', $display_function, $output);
// Insert URL
$output = str_replace('urlString', $display_url, $output);
$output = str_replace('displayMail', $display_mail, $output);
$output = str_replace('displayTc', $display_tcno, $output);
if($display_durum=='aktif')
{
$display_durum='<font color="#01DF01">Aktif</font>';
}
else if($display_durum=='pasif')
{
$display_durum='<font color="#FF0000">Pasif</font>';
}
$output = str_replace('display_durum', $display_durum,$output);
// Output
echo($output);
}
}else{
// Format No Results Output
$output = str_replace('urlString', 'javascript:void(0);', $html);
$output = str_replace('nameString', '<b>Sonuç Bulunamadı .</b>', $output);
$output = str_replace('functionString', '<a href="yenikayit.php">Yeni Kayıt Ekle</a>', $output);
$output = str_replace('displayMail', '', $output);
$output = str_replace('displayTc', '', $output);
$output = str_replace('display_durum', '', $output);
// Output
echo($output);
}
}
答案 0 :(得分:0)
AuthorizationExecuteWithPrivileges
&#13;
尝试方法=&#34;发布&#34;和$ _POST []代替或方法=&#34;得到&#34;和$ _GET []