function sender(url, data) {
var xhr = createXHR();
if (xhr) {
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
console.log(xhr.responseText);
console.log(xhr.responseText.toString());
var returnValue = xhr.responseText.toString();
console.log(returnValue);
return returnValue;
// firefox下xhr.responseText作为返回值失效的问题
// ie可以利用return来得到值。但firefox则不能,只能在readyState == 4 && status == 200时处理一个函数
// 这个函数应当作为一个参数传递入函数。有个奇怪现象你如果去除红线部分的注释,firefox又可以取到值。
// 估计是firefox使用ajax取值有个延时造成。
//return xhr.responseText.toString();
}
};
xhr.open("post", url, true);
// send(string) 仅适用于post请求
xhr.send(data);
} else {
//XMLHttpRequest对象创建失败
alert("浏览器不支持,请更换浏览器!");
}
}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char* get_cgi_data(FILE* fp, char* method)
{
char* input;
int len;
int size=1024;
int i=0;
if (strcmp(method, "GET") == 0) /**< GET method */
{
input = getenv("QUERY_STRING");
return input;
}
else if (strcmp(method, "POST") == 0) /**< POST method */
{
len = atoi(getenv("CONTENT_LENGTH"));
input = (char*)malloc(sizeof(char) * (size+1));
if (len == 0)
{
input[0] = '\0';
return input;
}
while (1)
{
input[i] = (char)fgetc(fp);
if (i == size)
{
input[i+1] = '\0';
return input;
}
--len;
if (feof(fp) || (!(len)))
{
i++;
input[i] = '\0';
return input;
}
i++;
}
}
return NULL;
}
int main(void)
{
char* input;
char* method;
char name[64];
char passwd[64];
int i=0;
int j=0;
printf("Content-type:text/html\n\n");
printf("The following is query result:");
method = getenv("REQUEST_METHOD");
input = get_cgi_data(stdin, method);
printf("string is: %s", input);
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有