|
|
|
ใช้ iframe ทำให้ โค้ดสว่น ajax ไม่ทำงาน บันทึกก็ไม่ได้ เป็นเพราะอะไรค่ะ ตอนเปิดกับโครมได้ค่ะ แต่พอเปิดกับ internet explorer ajax ไม่ทำงานค่ะ ต้องแก้ไขยังค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<iframe src='welcome.php' name="mainframe" width="100%" height="600" scrolling="Auto" frameborder="0" id="mainframe"></iframe>
แล้วเรียกใช้ welcome.php ทำให้ โค้ดสว่น ajax ไม่ทำงาน บันทึกก็ไม่ได้ เป็นเพราะอะไรค่ะ ตอนเปิดกับโครมได้ค่ะ แต่พอเปิดกับ internet explorer ajax ไม่ทำงานค่ะ ต้องแก้ไขยังค่ะ ขอบคุณค่ะ
หน้า welcome.php
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="style.css" />
<title>Untitled Document</title>
</head>
<script type="text/javascript" src="js/jquery-ui-1.8.5.custom.min.js"></script>
<link href="css/jquery-ui-1.8.5.custom.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="js/ajaxupload.3.5.js" ></script>
<link rel="stylesheet" type="text/css" href="js/styles.css" />
<script language="javascript">
var HttPRequest = false;
function insertAjax(Mode) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
var url = 'AjaxPHPposition.php';
var pmeters = "&tPOSITIONcode=" + encodeURI( document.getElementById("POSITIONcode").value) +
"&tPOSITIONname=" + encodeURI( document.getElementById("POSITIONname").value) +
"&tMode=" + Mode;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
function CheckNum(){
if (event.keyCode < 46|| event.keyCode > 57){
alert('กรุณากรอกข้อมูล ที่เป็นตัวเลข');
event.returnValue = false;
}
}
</script>
<script language="JavaScript">
var HttPRequest = false;
function editAjax(Mode) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'AjaxPHPposition.php';
if(Mode == "UPDATE")
{
var pmeters ="tPOSITIONcode=" + encodeURI( document.getElementById("POSITIONcode").value) +
"&tPOSITIONname=" + encodeURI( document.getElementById("POSITIONname").value) +
"&tMode=" + Mode;
}
if(Mode == "LIST")
{
var pmeters = "";
}
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
function ShowEdit(sCustomerID,sName,sName1)
{
document.getElementById("mySpan").style.display = '';
document.getElementById("POSITIONcode").value = sCustomerID;
document.getElementById("POSITIONcode2").value = sName;
document.getElementById("POSITIONname").value = sName1;
}
</script>
<script language="JavaScript">
var HttPRequest = false;
function deleteAjax(Mode,ID) {
var url = 'AjaxPHPposition.php';
var pmeters = "tMode=" + Mode +
"&tID=" + ID;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
function clearTextBox()
{
document.getElementById("POSITIONcode").value ="";
document.getElementById("POSITIONcode2").value ="";
document.getElementById("POSITIONname").value ="";
}
function showHide(elementid){
document.getElementById(elementid).style.display = '';
}
function Hide(elementid){
document.getElementById(elementid).style.display = 'none';
}
</script>
<script language="JavaScript">
var HttPRequest = false;
function Paging(Page) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'AjaxPHPposition.php';
var pmeters = 'myPage='+Page;
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
</script>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
function checkUserName(){
var filed= 'POSITIONcode';
var table = 'position';
$.post("ajaxservice.php", { filed1: filed,table1: table}, checkUserNameCompleted);
}
function checkUserNameCompleted(data){
// alert("Server return: " + data);
var txt= data;
document.getElementById("POSITIONcode").value = txt;
document.getElementById("POSITIONcode2").value = txt;
}
</script>
<body Onload="JavaScript:insertAjax('LIST');" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?
$filed='POSITIONcode';
$table= 'position' ;
$POSITIONcode=tsnumber2($filed,$table);
?>
<tr>
<td width="6%" height="25"> </td>
<td height="25" colspan="2"><span class="cs2">ข้อมูลตำแหน่ง</span></td>
<td width="24%"> </td>
<td width="25%" height="25"> </td>
</tr>
<tr>
<td height="25"> </td>
<td width="8%" height="25" class="cs3">รหัสตำแหน่ง</td>
<td width="37%" height="25"><input name="POSITIONcode2" type="text" id="POSITIONcode2" disabled="disabled" value="<? echo $POSITIONcode; ?>" />
<input name="POSITIONcode" type="hidden" id="POSITIONcode" value="<? echo $POSITIONcode; ?>" />
<input type="image" name="imageField" src="images/serch1.png" onclick="javascript:checkUserName();"/></td>
<td> </td>
<td height="25"> </td>
</tr>
<tr>
<td height="25"> </td>
<td height="25" class="cs3">ตำแหน่ง</td>
<td height="25"><input name="POSITIONname" type="text" id="POSITIONname" size="45" /></td>
<td height="25" colspan="2"> </td>
</tr>
<tr>
<td height="25"> </td>
<td height="25"> </td>
<td height="25"><input type="button" name="btnAdd" id="btnAdd" value="เพิ่มข้อมูล" onclick="JavaScript:insertAjax('ADD'),clearTextBox();" />
<span style="display='none';">
<input type="button" name="btnUpdate" id="btnUpdate" value="แก้ไขข้อมูล" onclick="JavaScript:editAjax('UPDATE'),clearTextBox();" />
</span></td>
<td> </td>
<td height="25"> </td>
</tr>
<tr>
<td height="25"> </td>
<td height="25"> </td>
<td height="25"> </td>
<td> </td>
<td height="25"> </td>
</tr>
<tr>
<td height="25"> </td>
<td height="25" colspan="4"><span id="mySpan"></span> </td>
</tr>
<tr>
<td height="25"> </td>
<td height="25"> </td>
<td height="25"> </td>
<td colspan="2" valign="top" align="center"> </td>
</tr>
</table>
<p> </p>
<p align="center"> </p>
</body>
</html>
Tag : PHP, MySQL, Ajax
|
|
|
|
|
|
Date :
2011-12-22 13:51:37 |
By :
sreesuda |
View :
1198 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<iframe src='welcome.php' name="mainframe" width="100%" height="600" scrolling="Auto" frameborder="0" id="mainframe"></iframe>
ถ้าไม่ใช้ iframe ต้องเขียนแบบไหนค่ะที่เปลียนหน้าเฉพาะส่วน
ขอบคุณค่ะ
|
|
|
|
|
Date :
2011-12-22 15:51:42 |
By :
sreesuda |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|