Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > JS object explanation needed

Reply
Thread Tools

JS object explanation needed

 
 
sammy
Guest
Posts: n/a
 
      07-06-2009
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
 
Reply With Quote
 
 
 
 
JR
Guest
Posts: n/a
 
      07-07-2009
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Explanation needed of binary operators NoNeYa Java 42 08-22-2007 09:03 PM
CONCEPT OF DAO IN J2EE --- EXPLANATION NEEDED soody Java 2 06-05-2007 08:35 AM
standalone in prolog: specs explanation needed VK XML 1 05-18-2006 10:43 PM
explanation needed on const pointers deepunayak@gmail.com C Programming 9 02-16-2006 10:31 PM
explanation needed for optical illusion in digital photo Eigenvector Digital Photography 27 08-02-2003 05:20 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57