/    Sign up×
Community /Pin to ProfileBookmark

Ajax action leads to missing PHP-Post-Variable from form

Hi.

I got a problem with some Post variables that are missing after calling an ajax method. I got the following form:

[code=html]
<form action=”action.php” method=”post”>

<span id=”id1″>
<select id=”sid1″ name=”sid1″ size=”1″ onChange=”ajaxMethod(this);”>
<option value=”-1″>Choose x before…</option>
</select>
</span>

</form>
[/code]

If i push the submit button without changing the value of the select box, i can see the variable

[CODE]$_POST[‘sid1’][/CODE]

But if i change the value of the select box and something like the following results

[code=html]
<form action=”action.php” method=”post”>

<span id=”id1″>
<select id=”sid1″ name=”sid1″ size=”1″ onChange=”ajaxMethod(this);”>
<option value=”1″>1</option>
<option value=”2″>2</option>
<option value=”3″>3</option>
</select>
</span>

</form>
[/code]

and then i try to submit the form, the variable

[CODE]$_POST[‘sid1’][/CODE]

is missing.

Can somebody give me a hint what i am doing wrong?

Thx

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Sep 16.2008 — How are you changing the value of the selectbox? What is your Ajax call code?

Eric
Copy linkTweet thisAlerts:
@c3hg1authorSep 16.2008 — This is the call:
[CODE]
selectCountry('id1', this, 'from');
[/CODE]


This is the called function.

By the way, i use the Facebook API...
[CODE]
function selectCountry(id, obj, direction)
{
var el = document.getElementById(id);
var country = obj.getValue();

var ajax = new Ajax();
ajax.responseType = Ajax.FBML;
ajax.ondone = function(data)
{
document.getElementById(id).setInnerFBML(data);
}
ajax.onerror = function() { show_error_dialog(el); };

var params = {'c':country,'d':direction};
ajax.post('http://blabla.de/footprints/update_cities.php', params);
}
[/CODE]

Maybe i have to change the constant Ajax.FBML to something else.

This could be the problem. I will check it out tonight..
×

Success!

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