(急!!!!)ajax如何获取cgi的返回值
c.c
#include < stdio.h > #include < stdlib.h > int main(void) { char *data; long m,n,num; printf("Content-Type:text/html;charset=gb2312\n\n"); data = getenv("QUERY_STRING"); if(data == NULL) printf("<P >错误!数据没有被输入或者数据传输有问题\n\n"); else if(sscanf(data,"m=%ld&n=%ld",&m,&n)!=2) printf("<P >错误!输入数据非法。表单中输入的必须是数字。\n\n"); else num = m*n;//printf("%ld。\n\n",num); return num; }
function Ajax(data){ var d=new Date(); xmlhttp.open("GET","/cgi-bin/c.cgi?m="+document.getElementById("Num_One").value+"&n="+document.getElementById("Num_Tow").value,true); xmlhttp.send(null); //document.getElementById('username_notice').innerHTML = process_request;//锟斤拷示状态 xmlhttp.onreadystatechange=function(){ if (4==xmlhttp.readyState){ if (200==xmlhttp.status){ var responseText = xmlhttp.responseText; if (responseText){ alert(responseText);//showInfo("username_notice",responseText); } }else{ alert("error!"); } } }}