| Author |
XMLHttpRequest() or GM_XMLHttpRequest help |
elmiguel
Member

Posts: 132
Location: Your Computer
Joined: 12.12.07 Rank: God |
|
OK I am having issues with both these functions and cannot seem to know why it is not working.
XMLHttpRequest():
var req = new XMLHttpRequest();
req.open('GET', 'https://developer.mozilla.org/En/Using_XMLHttpRequest', false);
req.send(null);
if(req.status == 200){
alert(req.responseText);
}
GM_XMLHttpRequest():
GM_xmlhttpRequest({
method: "POST",
url: "http://www.site.com",
headers: {"Content-Type": "WHAT IS THE MIME TYPE TO POST JUST TO A URL NOT A FORM!"},
data: "key" + encodeURI('stringToEncode')
}
});
I have been messing around with both GET and POST methods with both of functions (not in the same code of course). For some reason I get back null or nothing at all, and others I get the error feedback I put in. Does anyone have a working code for me to review and see what I am doing wrong?. I have looked over a lot of material on the web and all seems to be correct, but I can not perform this simple action.
Thanks in advance.
-elmiguel
The philosophy of one century is the common sense of the next. -Fortune Cookie
I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor
|
|
| Author |
RE: XMLHttpRequest() or GM_XMLHttpRequest help |
elmiguel
Member

Posts: 132
Location: Your Computer
Joined: 12.12.07 Rank: God |
|
Figured it out, it was my incorrect use of the headers and MIME Type
ex:
GM_xmlhttpRequest({
method: 'GET',
url: 'http://www.google.com',
headers: {
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
'Accept': 'application/xhtml+xml',
},
onblockedload: function(responseDetails) {
alert('Request for Google feed returned ' + responseDetails.status +
' ' + responseDetails.statusText + '\n\n' +
'Feed data:\n' + responseDetails.responseText);
}
});
The philosophy of one century is the common sense of the next. -Fortune Cookie
I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor
|
|
| Author |
RE: XMLHttpRequest() or GM_XMLHttpRequest help |
elmiguel
Member

Posts: 132
Location: Your Computer
Joined: 12.12.07 Rank: God |
|
OK, maybe not, works on google but when I try to request a page here it doesn't work:
var elements = ''; // whether null, blank or empty data is not being stored here.
GM_xmlhttpRequest({
method: 'GET',
url: 'http://www.hellboundhackers.org/challenges/timed/timed8/index.php',
headers: {
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
'Accept': 'text/plain',
},
onblockedload: function(responseDetails) {
elements = (responseDetails.responseText);// gets the data.
}
});
alert (elements); // if tried to store the data is lost.
[EDIT]: Changed MIME Type to: text/plain. It does get the data, but for some reason it will not store the data into a variable
The philosophy of one century is the common sense of the next. -Fortune Cookie
I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor
Edited by elmiguel on 29-07-09 13:58 |
|
| Author |
RE: XMLHttpRequest() or GM_XMLHttpRequest help |
SySTeM
-=[TheOutlaw]=-
Posts: 1524
Location: England, UK
Joined: 27.07.05 Rank: The Overlord |
|
How does GM_xmlhttpRequest handle cookies?
|
|
| Author |
RE: XMLHttpRequest() or GM_XMLHttpRequest help |
spyware
Member

Posts: 4190
Location: The Netherlands
Joined: 14.04.07 Rank: God Warn Level: 90
|
|
You need to send your HBH cookies with the request.

"The chowner of property." - Zeph Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term. - Carl Sagan Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor? - Ebert |
|
| Author |
RE: XMLHttpRequest() or GM_XMLHttpRequest help |
elmiguel
Member

Posts: 132
Location: Your Computer
Joined: 12.12.07 Rank: God |
|
|
function post(url, data) {
GM_xmlhttpRequest({
method: "POST",
url: url,
headers:{'Content-type':'application/x-www-form-urlencoded',
'Cookie' : 'PHPSESSID=<DATA>;fusion_user=<DATA>'},
data: "ans=" +encodeURI(data),
});
}
post('http://www.hellboundhackers.org/challenges/timed/timed8/index.php', a});
I am sending the Cookies but its not working
The philosophy of one century is the common sense of the next. -Fortune Cookie
I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor
|
|
| Author |
RE: XMLHttpRequest() or GM_XMLHttpRequest help |
COM
Banned

Posts: 800
Location:
Joined: 31.08.07 Rank: God |
|
If it doesn't automatically add it, you are going to have to add "Content-Length:" to that header.
K'aem'nhi kh'rn, K'aem'nhi kh'r, K'aem'nhi kh'rmnu.
I'a Y'gs-Othoth! |
|
|