2014-02-19 2 views
0

나는 mysql 데이터베이스에서 몇 가지 데이터를 얻으려고하고있어.트리거 할 PHP 파일을 실행

  1. 어떻게하면 자바 스크립트 파일에서 PHP를 트리거 할 수 있습니까?

  2. 어떻게 결과를 자바 스크립트 파일에서 다시 가져 옵니까?

+0

구글 아약스 ..... – xdazz

+1

감사합니다. 그것은 자바 스크립트 프레임 워크입니다. – Prabhudas

+0

Ajax 사용 ... – kcak11

답변

-2

자습서 :

function getInformation(){ 
$.post('xxx.php',{'param':'..value..'},function(response){ 
    console.log(response); 
}); 
} 

:

<script type="text/javascript"> 
function showInformation() 
{ 
if (window.XMLHttpRequest) 
    {// code for IE7+, Firefox, Chrome, Opera, Safari 
    xmlhttp=new XMLHttpRequest(); 
    } 
else 
{// code for IE6, IE5 
    mlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
} 
xmlhttp.onreadystatechange=function() 
{ 
if (xmlhttp.readyState==4 && xmlhttp.status==200) 
{ 
    console.log(xmlhttp.responseText); 
    //this is the result you can get here. 
} 
} 
xmlhttp.open("GET","xxx.php",true); 
//xxx.php is the php file you want to fetch data from 
    xmlhttp.send(); 
} 
</script> 

덕분에 여기

같은 작업을 할 수있는 JQuery와 스크립트입니다 참고 : 여기에 jquery.js fi가 포함되어 있습니다. 르. 당신이 jQuery를 사용 하시겠습니까

-1

사용 아약스는 MySQL의 DB에서 데이터를 얻을 수 있습니다.

당신은 귀하의 요구에 대한 스크립트를 사용할 수 http://www.w3schools.com/ajax/