/    Sign up×
Community /Pin to ProfileBookmark

I am having a problem with a AJAX.
it’s removing all the spaces in the info that i am passing

[CODE]

script language=”javascript”>
function saveXml (myText) {
alert(myText) // This alerts shows the text as it is and how i need it to be
var url2 = ‘saveFile.asp’;
xmldoc=myText
objHTTP = new ActiveXObject(‘Microsoft.XMLHTTP’);
objHTTP.Open(‘post’,url2,false);
objHTTP.setRequestHeader(‘Content-Type’,
‘application/x-www-form-urlencoded’);
objHTTP.send(“xmldoc=”+xmldoc);

strResult=objHTTP.responseText;
alert(strResult); // shows the text with no spaces
document.write(strResult)

}

</script>

[/CODE]

saveFile.asp

[CODE]

<%

dim MyXML
MyXML= request(“xmldoc”)
response.Write(MyXML) ‘ Shows the text noSpaces

Set fs = CreateObject(“Scripting.FileSystemObject”)
Set a = fs.CreateTextFile(“File Name.xml”)
a.WriteLine(MyXML)
a.Close

%>

[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@slaughtersJun 01.2007 — You seem to be assigning the contents of a text string to a variable without quoting it.

This:

xmldoc = "Bob is bad"

objHTTP.send("xmldoc="+xmldoc)

would send: xmldoc=Bob is bad

Try objHTTP.send("xmldoc=""+xmldoc+""") and see if that fixes anything.
Copy linkTweet thisAlerts:
@moiseszaragozaauthorJun 01.2007 — Thanks 4 the help but what i am getting now is a set of " " in front and at the end but still no spaces.

I try hard coding some text with spaces but still it removed the spaces
×

Success!

Help @moiseszaragoza 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.16,
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,
)...