|
 |
|
ไฟล์ที่เรียกผ่าน สคริปเอเจ็ค ให้มีการเรียก คำสั่งจาวาสคริปอีกครั้งได้เปล่าครับ |
|
 |
|
|
 |
 |
|
ผมลองทำแบบนี้ แต่มันก็ไม่ทำงานครับ
--------
ex_call_ajax.php
---------------
<input type="submit" name="button" id="button" value="Submit" onClick="sendedit('field','value','id_prs','lang','retrunajax');">
<label id="retrunajax"></label>
<script>
function sendedit(field,value,id_prs,lang,id_field_label){
//alert(field);alert(value);alert(id_prs);alert(lang);
function Inint_AJAX() {
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {} //IE
try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript
alert("XMLHttpRequest not supported")
return null
}
var req = Inint_AJAX(); // Object
//alert(field);
req.open('GET', './ex_trun_call.php?value='+encodeURIComponent(value)+'&field='+encodeURIComponent(field)+'&lang='+encodeURIComponent(lang)+'&id_prs='+encodeURIComponent(id_prs), true); //
req.onreadystatechange = function() { //
if (req.readyState==4) {
if (req.status==200) { //
var data=req.responseText; //
document.getElementById(id_field_label).innerHTML=""+data; //
}
}
};
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); //
req.send(null); //
}
</script>
------------------------
ex_trun_call.php
----------------------
Code (PHP)
<?
$s.="<script type=\"text/javascript\"> alert('ok'); </script>";
$s.="fdfdfdf";
echo $s;
?>
Tag : PHP, JavaScript

|
|
 |
 |
 |
 |
Date :
2013-05-09 11:00:51 |
By :
antz |
View :
775 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำไมไม่ทำในหน้าที่เรียก Ajax ล่ะครับ 
|
 |
 |
 |
 |
Date :
2013-05-09 12:20:55 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ่อครับ ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2013-05-09 12:49:29 |
By :
antz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|