Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
157
rated 0 times [  158] [ 1]  / answers: 1 / hits: 55521  / 14 Years ago, thu, november 25, 2010, 12:00:00

I'm trying to write an XMLHttpRequest using the POST method. I have managed to use XMLHttpRequest in the past using the GET method but am struggling with POST.



Here's my code:



var xmlhttp = null;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp = new ActiveXObject(Microsoft.XMLHTTP);
}

var url = http://www.mysite.com/script.php;
var params = var=1;
xmlhttp.open(POST, url, true);
xmlhttp.send(params);


It basically calls a PHP script which then adds some information to a database.


More From » ajax

 Answers
38

Okay I've managed to sort it.



Odd reason though, might be sandbox security related, but rather than have the full URL address, I have just used the relative path to the file, and now it works.



Thank you all for your support.


[#94849] Monday, November 22, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
madelyn

Total Points: 449
Total Questions: 100
Total Answers: 100

Location: Seychelles
Member since Fri, May 7, 2021
3 Years ago
madelyn questions
Wed, Jul 28, 21, 00:00, 3 Years ago
Wed, Jul 14, 21, 00:00, 3 Years ago
Sat, Nov 7, 20, 00:00, 4 Years ago
Thu, Sep 3, 20, 00:00, 4 Years ago
;