/    Sign up×
Community /Pin to ProfileBookmark

Extra spaces after AJAX responseText

I have a page that contains a form. The way I want it to work is I want to have the user select one of three radio buttons, and once that happens a set of checkboxes will display for them to select.

I want to do this all in Ajax so the page won’t have to refresh after every click but I’m having a problem on the radio button section. In my PHP script I’m attempting to return something like this:

echo “show_checkboxes”;

and back in the JavaScript function I compare the xmlHttp.responseText to “show_checkboxes” to see if they match. However they do not match correctly and the responseText actually looks like “show_checkboxes “. I tried to trim the response back in PHP but had no luck.

Hopefully that made sense.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@jkelmauthorDec 18.2007 — For more information, the way it's being setup is such that if it finds a match with "show_checkboxes" it will basically submit the page to itself and work from there. This isn't actually an ajax approach to it (just something I was trying), but I was unable to think of a way to do this with straight ajax.

If anyone has an idea about how to achieve this with full ajax I would be very interested in hearing.
×

Success!

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