Ajax를 사용하여 다른 PHP 스크립트를 호출 할 때마다 체크 상자가 생기고, 이제는 PHP 스크립트에서 단추가있는 텍스트 상자가 3 개 있으며 Button을 누를 때마다 Ajax가 다른 PHP 스크립트를 호출하도록 수행됩니다. 그 모두가 그냥이Ajax를 사용하여 다른 Ajax가있는 PHP 스크립트를 호출 할 수 있습니까?
PHP처럼!, 같은 페이지에 미리 형성되어있다 -> 아약스 -> PHP -> 아약스 -> PHP
이 가능하거나 처리 할 너무 많은가요?!
처음 아약스는 다음과 같습니다
<script type = 'text/javascript'>
function load(cb, pos)
{
if (cb.checked == false)
{
document.getElementById(pos).innerHTML="";
return;
}
if (window.XMLHttpRequest)
xmlhttp = new XMLHttpRequest();
else
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
document.getElementById(pos).innerHTML = xmlhttp.responseText;
}
xmlhttp.open('GET', "trying.inc.php?pass='true'", true);
xmlhttp.send();
}
</script>
"Tring.inc.php"에 두 번째 아약스 :
"Trying2.inc.php"를 호출<script type = 'text/javascript'>
function check()
{
if (window.XMLHttpRequest)
xmlhttp = new XMLHttpRequest();
else
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
document.getElementById('adiv').innerHTML = xmlhttp.responseText;
}
Parameters = "OldPass="+document.getElementById('OldPass').value+"&newPass="+document.getElementById('newPass').value+"&Confirm="+document.getElementById('ConfirmPass').value;
xmlhttp.open('POST', 'Trying2.inc.php', true);
xmlhttp.setRequestHeader ('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.send(Parameters);
}
</script>
.
"trying.inc.php"페이지에서 Ajax가 "trying2.inc.php"를 호출 할 때 작동하지만 메인 페이지에서 "try.inc.php"를 호출 할 수 있습니다. inc.php "는"trying2.inc.php "를 호출 할 수 없습니다. 더 설명하는 방법을 모르므로 분명합니다. 그것을 달성하기 위해 내가 할 수있는 일이 있다면 코드로 지원하십시오. 임 목적을 위해 이것을하는 Im는 저에 가혹하지 않다, 선행에 감사하십시오.
이보다 중첩 된 아약스 스크립트를 사용하는 것이 좋습니다. –
개발자 도구에서 네트워크 탭을 보셨습니까? 표시된 오류가 있습니까? 'Origin http : // localhost : 8080이 Access-Control-Allow-Origin에 의해 허용되지 않습니다. '와 같은 오류가 발생하면'header ('Access-Control-Allow-Origin : * ');'맨 처음 ** HTH 2.inc.php ** 파일을 시도하십시오. – JohnnyQ
스크립트를'.innerHTML'에 넣으면 실행할 수 없습니다. 스크립트를 동적으로로드하는 유일한 방법은'script' 노드를 명시 적으로 생성하는 것입니다. – Barmar