On Jul 6, 8:46*pm, sammy <sa...@voidstar.com> wrote:
> I have finaly had reason to look at JS, but I can't find any detailed
> info on the web about objects.
> I trying to create a requiest for GM_xmlhttpRequest()
>
> // * * * *obj1 = { *method:"POST", *url:"192.168.0.6:7777",
> // * * * * * * * * * * * * * * *headers:{
> // * * * * * * * * * * * * * * *"User-Agent":"monkeyagent",
> // * * * * * * * * * * * * * * *"Accept":"text/monkey,text/xml"},
> // * * * * * * * * * * * * * * *onload:function(details) {
> // * * * * * * * * * * * * * * *alert([
> // * * * * * * * * * * * * * * *details.status,
> // * * * * * * * * * * * * * * *details.statusText,
> // * * * * * * * * * * * * * * *details.readyState,
> // * * * * * * * * * * * * * * *details.responseHeaders,
> // * * * * * * * * * * * * * * *details.responseText].join("\n")) }
> // * * * * * * * * * * * * * * *};
>
> The above is almost verbatim from mozilla docs ( which I can't now find )
>
> * * * * *obj1 = { *method:"POST", *url:"http://voidstar:7777",
> * * * * * * * * * * * * * * * *headers:{
> * * * * * * * * * * * * * * * *"User-Agent":"monkeyagent",
> * * * * * * * * * * * * * * * *"Accept":"text/monkey,text/xml",
>
> "Content-type":"application/x-www-form-urlencoded" *},
> * * * * * * * * * * * * * * * *data: "data here?" *};
>
> // * * * *obj1 = { *method:"POST", *url:"http://voidstar:7777",
> // * * * * * * * * * * * * * * *headers:{
> // * * * * * * * * * * * * * * *"User-Agent":"monkeyagent",
> // * * * * * * * * * * * * * * *"Accept":"text/monkey,text/xml" *}
> // * * * * * * * * * * * * * * * *};
> // * * * *obj1.data = response
> GM_xmlhttpRequest( obj1 )
>
> I guess I am not sure what is realy happening in the original example.
> Is it creating object with method , headers and "?? nameless function"
> members?
> I have tried:
> obj1.data = posted_data_string
> to add member var data but no joy, so how can I add my data string to this?
>
> Many thanks
There is an example at the GreaseMonkey site:
http://diveintogreasemonkey.org/api/...tprequest.html
The following code fetches the Atom feed from
http://greaseblog.blogspot.com/
and displays an alert with the results.
GM_xmlhttpRequest({
method: 'GET',
url: 'http://greaseblog.blogspot.com/atom.xml',
headers: {
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
'Accept': 'application/atom+xml,application/xml,text/xml',
},
onload: function(responseDetails) {
alert('Request for Atom feed returned ' +
responseDetails.status +
' ' + responseDetails.statusText + '\n\n' +
'Feed data:\n' + responseDetails.responseText);
}
});
--
JR