/    Sign up×
Community /Pin to ProfileBookmark

sending xml object to php

Hi,
I need to send username received from html to php as xml object. There is some problem in my code.

function adduser()

{

uname = document.getElementById(“uname”).value;

alert(uname);

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)

{

alert (“Browser does not support HTTP Request”)

return

}

var url=”sendxml.php”

param = “<profile>” +”<username>”+escape(uname)+”</username>”+”</profile>”

xmlstring=xmlToString(param);
alert(“entered”);

alert(xmlstring);

xmlHttp.setRequestHeader(“Content-Type”,”application/x-www-form-urlencoded”)

xmlHttp.onreadystatechange=stateChanged

xmlHttp.open(“POST”,url,true)

xmlHttp.send(“param=”+xmlstring)

}

function xmlToString(xmlObj) {
if (navigator.appName == “Netscape”)
{
return (new XMLSerializer()).serializeToString(xmlObj);
}
if (navigator.appName == “Microsoft Internet Explorer”)
{
return xmlObj.xml;
}
}

Can anybody help me?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@scragarJan 07.2009 — That's javascript, not PHP, post the problem there.

AND USE [code] TAGS AROUND YOU CODE!

If you don't it becomes hard to read like your post, I passed by your thread three times(I spotted the code outside of the code tags, figured it would be too much work for me to copy/paste it and restore some reasonable levels of indent before i could understand the code, and closed the tab without reading the post) before I decided to post this(which I am doing only because I have nothing else to do for the next 30 mins or so).
Copy linkTweet thisAlerts:
@sirfiraauthorJan 07.2009 — I am a new guy. Thank You for your help.

That's javascript, not PHP, post the problem there.

AND USE [code] TAGS AROUND YOU CODE!

If you don't it becomes hard to read like your post, I passed by your thread three times(I spotted the code outside of the code tags, figured it would be too much work for me to copy/paste it and restore some reasonable levels of indent before i could understand the code, and closed the tab without reading the post) before I decided to post this(which I am doing only because I have nothing else to do for the next 30 mins or so).[/QUOTE]
×

Success!

Help @sirfira 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...