|
 |
|
ทำไม ie6 ถึง error ครับ พอจะมีทางแก้มั้ย บรรทัดนี้อ่ะคับ ใน ff ไม่ error และทำงานได้ดี(เพื่อให้ล๊อคบราวเซอร์ก่อนได้ค่ามา (synchronize)) |
|
 |
|
|
 |
 |
|
$.ajaxSetup({async: false});
ลองเอา
;
ออกไป
ให้เป็น
$.ajaxSetup({async: false})
|
 |
 |
 |
 |
Date :
2009-11-18 12:10:31 |
By :
danya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแล้วครับ ff ไม่ error แต่ ie6 error เหมือนเดิม
แต่เอ ทำไม เอา ; ออก แต่ ff กลับไม่ error 
|
 |
 |
 |
 |
Date :
2009-11-18 12:15:43 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองโค้ดนี้ดูลอง ie6-7 ไม่มีปัญหานะ
<!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" dir="ltr" lang="th" xml:lang="th">
<head>
<title>untitle</title>
<script type="text/javascript" src="/firstmeditech/.js/jquery.js"></script>
<script type="text/javascript">
$.ajaxSetup({
async: false
});
$(function(){
var response='';
$.ajax({
url:'?test',
type:'post',
dataType:'html',
success:function(data){
response = data;
}
});
alert('respone='+response);
});
</script>
</head>
<body>
</body>
</html>
|
 |
 |
 |
 |
Date :
2009-11-18 12:22:12 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คับโค้ดของพี่ num ไม่ error
แต่ของผม error ลองเอาโค้ดมาแปะดูเผื่อว่า จะเห็นข้อบกพร่อง
Code (PHP)
<script type="text/javascript" src="media/javascript/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
var init_province_id = <?=$hotel_data['province_id']?>;
var init_amphur_id = <?=$hotel_data['amphur_id']?>;
var regex_picture = /\.(jpe?g|gif|png)$/i;
var regex_homepage = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
var regex_email = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
$(document).ready(function()
{
//เพิ่มฟังชั่นให้กับ jQuery
$.fn.disable = function(){
return this.each( function(){
if (typeof this.disabled != "undefined") this.disabled = true;
});
}
$.fn.enable = function(){
return this.each( function(){
this.disabled = false;
});
}
// เปลี่ยนจังหวัด ให้โหลดอำเภอใหม่
$('#province_id').change(function()
{
loadAmphur();
}
);
// จังหวัดปัจจุบัน
$('#province_id option[value='+init_province_id+']').attr('selected', 'selected');
//ดึงค่าอำเภอทั้งหมด
loadAmphur();
// แสดงอำเภอของโรงแรม
$('#amphur_id option[value='+init_amphur_id+']').attr('selected', 'selected');
// ตรวจสอบข้อมูลตอนซับมิตฟอร์ม
$('form').submit(function()
{
var hotel_hotel_name = $('#hotel_hotel_name').val();
var hotel_short_detail = $('#hotel_short_detail').val();
var hotel_hotel_address = $('#hotel_hotel_address').val();
var hotel_hotel_phone = $('#hotel_hotel_phone').val();
var hotel_hotel_email = $('#hotel_hotel_email').val();
var hotel_name = $('#hotel_name').val();
var hotel_surname = $('#hotel_surname').val();
var hotel_hotel_picture = $('#hotel_hotel_picture').val();
var hotel_hotel_homepage = $('#hotel_hotel_homepage').val();
if ( ! hotel_hotel_name || ! hotel_short_detail || ! hotel_hotel_address || ! hotel_hotel_phone || ! hotel_hotel_email || ! hotel_name || ! hotel_surname)
{
alert('กรอกข้อมูลไม่ครบ');
return false;
}
if (hotel_hotel_picture != '')
{
if ( ! regex_picture.test(hotel_hotel_picture))
{
alert('ชนิดรูปไม่ถูกต้อง');
return false;
}
}
if ( ! regex_email.test(hotel_hotel_email))
{
alert('อีเมลไม่ถูกต้อง');
return false;
}
if (hotel_hotel_homepage != '')
{
if ( ! regex_homepage.test(hotel_hotel_homepage))
{
alert('url โฮมเพจโรงแรม ไม่ถูกต้อง');
return false;
}
}
return true;
});
});
// ฟังชั่น โหลดรายชื่ออำเภอ
function loadAmphur()
{
var province_id = $('#province_id').val();
$.ajaxSetup({async: false});
$('#amphur_id').disable().load('ajax.php', {type: 'amphur_option_tags', province_id: province_id}, function()
{
$(this).enable();
}
);
} // loadAmphur()
</script>
ซึ่งตอนแรกที่เขียนไม่คิดจะให้ซิงโคร เลยมี disable ก่อน แค่ลองเปลี่ยนวิธี เพิ่มโค้ดเข้าไปก็ error
|
 |
 |
 |
 |
Date :
2009-11-18 12:38:06 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่รู้ว่าเป็นเพราะอะไร ลอง alert ค่ามาดูเห็นว่าเกี่ยวกับ selected
alert($('#province_id option[value='+init_province_id+']').size());
alert($('#amphur_id option[value='+init_amphur_id+']').size());
หรือจะเป็นเพราะ disabled ไว้ ลองเปลี่ยนให้เป็น disabled=false ก่อนแล้วค่อย set selected ไม่รู้หายป่าว
|
 |
 |
 |
 |
Date :
2009-11-18 13:18:18 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
alert($('#amphur_id option[value='+init_amphur_id+']').size()); อันนี้ได้ 0
แก้ได้แล้วครับ ตอนนี้ บรรทัด $ajaxSetup(); ไม่ error แล้ว
เพราะเพิ่มคอมเมนต์
// $('#amphur_id option[value='+init_amphur_id+']').attr('selected', 'selected');
แต่ ผมยังไม่รู้สาเหตุเลย
ถึงแม้จะเอา disable enable ออก แล้ว เอาคอมเมนต์บรรทัดที่บอกมาออก ก็ยัง error คาดว่าไม่น่าเกี่ยวกับ disable ครับ
ตอนนี้ มันไม่เลือกอำเภอเดิมให้เพราะ ใส่คอมเมนต์บรรทัดนั้นไป แต่โค้เดิมทำงานได้บน ff
ขอรีแฟคเตอร์ หน่อยนะคับ เผื่อจะอ่านได้ง่ายขึ้น โค้ดนี้ทำงานบน ff แต่ยัง error บน ie6
Code (PHP)
<script type="text/javascript" src="media/javascript/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
var init_province_id = <?=$hotel_data['province_id']?>;
var init_amphur_id = <?=$hotel_data['amphur_id']?>;
var regex_picture = /\.(jpe?g|gif|png)$/i;
var regex_homepage = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
var regex_email = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
$.ajaxSetup({async: false});
$(document).ready(function()
{
// เปลี่ยนจังหวัด ให้โหลดอำเภอใหม่
$('#province_id').change(function()
{
loadAmphur();
});
// จังหวัดปัจจุบัน
$('#province_id option[value='+init_province_id+']').attr('selected', 'selected');
//ดึงค่าอำเภอทั้งหมด
loadAmphur();
// แสดงอำเภอของโรงแรม
$('#amphur_id option[value='+init_amphur_id+']').attr('selected', 'selected');
// ตรวจสอบข้อมูลตอนซับมิตฟอร์ม
$('form').submit(function()
{
var hotel_hotel_name = $('#hotel_hotel_name').val();
var hotel_short_detail = $('#hotel_short_detail').val();
var hotel_hotel_address = $('#hotel_hotel_address').val();
var hotel_hotel_phone = $('#hotel_hotel_phone').val();
var hotel_hotel_email = $('#hotel_hotel_email').val();
var hotel_name = $('#hotel_name').val();
var hotel_surname = $('#hotel_surname').val();
var hotel_hotel_picture = $('#hotel_hotel_picture').val();
var hotel_hotel_homepage = $('#hotel_hotel_homepage').val();
if ( ! hotel_hotel_name || ! hotel_short_detail || ! hotel_hotel_address || ! hotel_hotel_phone || ! hotel_hotel_email || ! hotel_name || ! hotel_surname)
{
alert('กรอกข้อมูลไม่ครบ');
return false;
}
if (hotel_hotel_picture != '')
{
if ( ! regex_picture.test(hotel_hotel_picture))
{
alert('ชนิดรูปไม่ถูกต้อง');
return false;
}
}
if ( ! regex_email.test(hotel_hotel_email))
{
alert('อีเมลไม่ถูกต้อง');
return false;
}
if (hotel_hotel_homepage != '')
{
if ( ! regex_homepage.test(hotel_hotel_homepage))
{
alert('url โฮมเพจโรงแรม ไม่ถูกต้อง');
return false;
}
}
return true;
});
});
// ฟังชั่น โหลดรายชื่ออำเภอ
function loadAmphur()
{
var province_id = $('#province_id').val();
$('#amphur_id').load('ajax.php', {type: 'amphur_option_tags', province_id: province_id});
} // loadAmphur()
</script>
|
 |
 |
 |
 |
Date :
2009-11-18 13:51:20 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คราวนี้ ie6 มันซิงค์ ให้คับถึงแม้ว่าจะมี error แต่ ff ทำงานซิงค์ให้คับ (ลองกับ sleep())
ถ้าเอาบรรทัด $.ajaxSetup() ออก ไม่ซิงโคร ทั้ง ff และ ie6
แต่ตอนนี้ใน ie6 มันไม่เช็ค ค่าบนฟอร์มให้คับ
Code (PHP)
<script type="text/javascript" src="media/javascript/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
var init_province_id = <?=$hotel_data['province_id']?>;
var init_amphur_id = <?=$hotel_data['amphur_id']?>;
var regex_picture = /\.(jpe?g|gif|png)$/i;
var regex_homepage = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
var regex_email = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
$.ajaxSetup({async: false});
$(document).ready(function()
{
// จังหวัดปัจจุบัน
$('#province_id option[value='+init_province_id+']').attr('selected', 'selected');
// เปลี่ยนจังหวัด ให้โหลดอำเภอใหม่
$('#province_id').change(function()
{
loadAmphur();
}).change();
// แสดงอำเภอของโรงแรม
$('#amphur_id option[value='+init_amphur_id+']').attr('selected', 'selected');
// ตรวจสอบข้อมูลตอนซับมิตฟอร์ม
$('form').submit(function()
{
var hotel_hotel_name = $('#hotel_hotel_name').val();
var hotel_short_detail = $('#hotel_short_detail').val();
var hotel_hotel_address = $('#hotel_hotel_address').val();
var hotel_hotel_phone = $('#hotel_hotel_phone').val();
var hotel_hotel_email = $('#hotel_hotel_email').val();
var hotel_name = $('#hotel_name').val();
var hotel_surname = $('#hotel_surname').val();
var hotel_hotel_picture = $('#hotel_hotel_picture').val();
var hotel_hotel_homepage = $('#hotel_hotel_homepage').val();
if ( ! hotel_hotel_name || ! hotel_short_detail || ! hotel_hotel_address || ! hotel_hotel_phone || ! hotel_hotel_email || ! hotel_name || ! hotel_surname)
{
alert('กรอกข้อมูลไม่ครบ');
return false;
}
if (hotel_hotel_picture != '')
{
if ( ! regex_picture.test(hotel_hotel_picture))
{
alert('ชนิดรูปไม่ถูกต้อง');
return false;
}
}
if ( ! regex_email.test(hotel_hotel_email))
{
alert('อีเมลไม่ถูกต้อง');
return false;
}
if (hotel_hotel_homepage)
{
if ( ! regex_homepage.test(hotel_hotel_homepage))
{
alert('url โฮมเพจโรงแรม ไม่ถูกต้อง');
return false;
}
}
return true;
});
});
// ฟังชั่น โหลดรายชื่ออำเภอ
function loadAmphur()
{
var province_id = $('#province_id').val();
$('#amphur_id').load('ajax.php', {type: 'amphur_option_tags', province_id: province_id});
} // loadAmphur()
</script>
|
 |
 |
 |
 |
Date :
2009-11-18 14:08:19 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|