我有原型JS Ajax请求,基本上是这样的:翻译prototypejs Ajax请求的libcurl在C++
new Ajax.Request("http://www.example.com", {
method: 'post',
postBody: '{"params":{"first":"one", "second":"two"}}',
contentType: 'text/json'
requestHeaders: {
'Content-Length': 42
}
onComplete: function() {}
});
我试着libcurl中像这样的:
struct curl_slist *slist = NULL;
slist = curl_slist_append(slist, "Content-Type: text/json");
curl_easy_setopt(curl, CURLOPT_URL, "http://www.example.com");
curl_easy_setopt(curl, CURLOPT_HEADER, slist);
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 42);
curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, "{\"params\":{\"first\":\"one\", \"second\":\"two\"}}");
但在在服务器端,它不像原型实现那样识别后置主体。
我还没有能够取得任何进展,所以我希望这里有人能够提供我需要的见解。谢谢!
有`,`在缺少你AJAX请求(在onComplete和requestHeader之前) – giraff 2011-02-21 08:22:37