/    Sign up×
Community /Pin to ProfileBookmark

I want to change the send data method in the code from GET TO POST

Hello Everybody

I have ajax code send data by GET method to php page

I want to change the send data method in the code from GET TO POST

THE CODE

[code]
function Add_Site(){
var site_name = document.getElementById(‘site_name’).value;
var site_desc = document.getElementById(‘site_desc’).value;
var site_url = document.getElementById(‘site_url’).value;

if (site_name == “” || site_desc == “” || site_url == “”) {
document.getElementById(‘show_result’).innerHTML = “fields is empty”;
}
else {
Http.onreadystatechange = function(){
if (Http.readyState == 4) {
document.getElementById(‘show_result’).innerHTML = “”;
document.getElementById(‘show_result’).innerHTML = Http.responseText;
}
else {
document.getElementById(‘show_result’).innerHTML = “”;
document.getElementById(‘show_result’).innerHTML = “Loading”;
}
}

rand = Math.random() * 999999999;
url = “addSite.php?site_name=” + site_name + “&site_desc=” + site_desc + “&site_url=” + site_url + “&rand=” + rand;
Http.open(“GET”, url, true);
Http.send(null);
}
}
[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 05.2009 — <i>
</i>...
Http.open("[COLOR="Blue"]POST[/COLOR]", url, true);
...
×

Success!

Help @lionking spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...