/    Sign up×
Community /Pin to ProfileBookmark

javascript query string

var x=document.getElementById(“addx”).value;
var y=document.getElementById(“addy”).value;

xml2http.open(“GET”,”update.php?city_id='”+str+”‘&x='”+x+”‘&y='”+y+”‘”,true);

xml2http.send();

Hi guys,

what am i doing wrong here ??
i want to pass multiple query string….

somehow the page never get’s called.
it works if i only put in query string “str”

HELP!! ?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@tirnaFeb 03.2011 — 
what am i doing wrong here ??
[/QUOTE]


Maybe lots of things but we can't see the rest of your code.

To debug your query string you can put it into a separate variable first and then alert() it to see exactly what it is before appending it to the url. Your errors should then be easily spotted.

Also, with that type of data in your query string, it's a good idea to encodeURI() it as well.
Copy linkTweet thisAlerts:
@rnd_meFeb 03.2011 — you have aposes (') in your url, take them out...

also, you should use encodeURIComponent() to encode url params, which makes sub-urls safe to use as parameters, even if those urls themselves have parameters...
Copy linkTweet thisAlerts:
@sagunauthorFeb 03.2011 — cool,

i will try that

and thanks for the enclode() thing

if i could see an example would be gr8.

Tx.
Copy linkTweet thisAlerts:
@tirnaFeb 03.2011 — cool,

i will try that

and thanks for the enclode() thing

if i could see an example would be gr8.

Tx.[/quote]


If you google encodeuri you will get a truck load of hits and code examples.
×

Success!

Help @sagun 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.28,
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,
)...