我有原型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