ยกตัวอย่าง 1 เพจ
1.หน้าposting.php
-$template->set_filenames(array(
'body' => 'posting_body.html')
);
2.หน้า posting_body.html
-<!-- INCLUDE posting_layout.html -->
3.หน้าposting_layout.html
-<!-- INCLUDE overall_header.html -->
-<!-- INCLUDE posting_editor.html -->
-<!-- INCLUDE overall_footer.html -->
4.หน้าposting_editor.html
-<dl style="clear: left;">
<dt><label for="fmax_cps_name">{L_FMOD_SUBJECT_CUSTOMER}:</label>
</dt>
<dd>
<input autocomplete="off" type="text" id="fmax_cps_name" name="fmax_cps_name" class="fmax_cps_name inputbox autowidth" size="60" maxlength="<!-- IF S_NEW_MESSAGE -->80<!-- ELSE -->64<!-- ENDIF -->" tabindex="2" value="{NAME}{NAMEC}" <!-- IF CO_SUB !== 1 --> disabled <!-- ENDIF --> />
<span id="cps_id_error" class="error"></span>
<input type="hidden" name="fmax_cps_id" class="fmax_cps_id" value="{ID}">
<input type="hidden" name="fmax_cps_id_o" id="fmax_cps_id_o" value="{ID}">
</dd>
</dl>
เรียกคลาส fmax_cps_name
5.หน้าoverall_footer.html
jQuery('.fmax_cps_name').typeahead({
ajax : './ajax.php?mode=fmax_customer&',
onSelect : displayResult,
}).on('input',function(e){
fmax_cps_name = jQuery('#fmax_cps_name').val();
if(fmax_cps_name.length>1) {
cps_validate();
}
});
6.หน้าส่ง modeไปหน้า ajax.php
case 'fmax_customer':
$query = request_var('query', '');
$query = strtoupper($query);
$sql = "SELECT id, AES_DECRYPT( CompanyID, '". constant('M_KEY') ."' ) AS name1 " .
" , AES_DECRYPT( CompanyName, '". constant('M_KEY') ."' ) AS name2 " .
" FROM cps " .
" WHERE AES_DECRYPT( CompanyID, '". constant('M_KEY') ."' ) LIKE '".$db->sql_escape($query)."%'" .
" ORDER BY AES_DECRYPT( CompanyID, '". constant('M_KEY') ."' ) ASC " .
" LIMIT 0,8";
$re = $db->sql_query($sql);
//echo $sql;
$response = array();
while($fmax_row = $db->sql_fetchrow($re)){
$a_fmax_row = array('id'=>$fmax_row['id'], 'name'=> $fmax_row['name1'] .' >> ' . $fmax_row['name2']);
$response[] = $a_fmax_row;
}
echo json_encode($response);
break;
หน้านี้select ละก็ถอดรหัสตามอักขระมา8ตัว และเข้ารหัสเป็นjson และนี่เป็นข้อมูลในautocomplete
การใช้ autocomplate ajax ในphpbb3
Moderator: mindphp, ผู้ดูแลกระดาน
-
- PHP VIP Members
- โพสต์: 1527
- ลงทะเบียนเมื่อ: 18/08/2014 10:01 am
-
- Similar Topics
- ตอบกลับ
- แสดง
- โพสต์ล่าสุด
-
-
โพสต์ใหม่ การใช้ php Ajax แสดงผล เมื่อเลือกรายการใน list แล้วเปลี่ยนรูปภาพที่แสดง
โดย bankjittapol » 30/11/2019 7:13 pm » ใน jQuery & Ajax Knowledge - 0 ตอบกลับ
- 3035 แสดง
-
โพสต์ล่าสุด โดย bankjittapol
30/11/2019 7:13 pm
-
-
- 1 ตอบกลับ
- 1693 แสดง
-
โพสต์ล่าสุด โดย Kimboei
09/09/2015 12:20 pm
-
-
โพสต์ใหม่ Ajax PHP ค้นหาโดยพิมพ์อักขระในฟิลด์อินพุต
โดย theoneozz » 10/01/2019 2:57 pm » ใน jQuery & Ajax Knowledge - 0 ตอบกลับ
- 2411 แสดง
-
โพสต์ล่าสุด โดย theoneozz
10/01/2019 2:57 pm
-
-
-
โพสต์ใหม่ การค้นหาข้อมูลโดยใช้ AJAX PHP
โดย Parichat » 10/01/2018 2:54 pm » ใน jQuery & Ajax Knowledge - 0 ตอบกลับ
- 2360 แสดง
-
โพสต์ล่าสุด โดย Parichat
10/01/2018 2:54 pm
-
-
- 0 ตอบกลับ
- 2305 แสดง
-
โพสต์ล่าสุด โดย Parichat
09/01/2018 12:12 am
-
- 0 ตอบกลับ
- 1670 แสดง
-
โพสต์ล่าสุด โดย thatsawan
26/05/2014 5:51 pm
-
-
โพสต์ใหม่ Yii Framework ติดปัญหาการบันทึกข้อมูลด้วย Ajax
โดย chornma » 15/11/2014 2:34 am » ใน Programming - PHP - 10 ตอบกลับ
- 5679 แสดง
-
โพสต์ล่าสุด โดย chornma
19/11/2014 5:07 pm
-
ผู้ใช้งานขณะนี้
สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 80