jQuery AJAX call ignoring underscores in place of spaces -
i have code extracts value dropdown menu , uses value parameter in ajax call.
the code looks this:
html
<select class='formdropdown ' id='ass-assessmentreason' name='ass-assessmentreason'> <option value='emergency'>emergency</option> <option value='follow-up'>follow-up</option> <option value='nurse call'>nurse call</option> </select>
js
$('#ass-assessmentreason').change(function() { var selectedoption = $(this).find(":selected").text().replace(/ /g,"_"); // replace whitespace _ url transportation console.debug(selectedoption); $.ajax({ type: "post", url: "otrfollowup.php", data: "followup=" + selectedoption,
i've cut off rest of code works absolutely fine when selected dropdown option has no spaces, truncates value space in it.
as can see attempted remedy temporarily replacing spaces underscores , reversing in otrfollowup.php. don't understand when @ console debugger see 'nurse_call' when @ url tried call see 'otrfollowup.php?followup=nurse
for reason it's ignoring underscores, sending dropdown value spaces intact, truncating proper option value , breaking rest of script. since console.debug() right before ajax call showing replacing spaces underscores, i'm stumped why it's doing this.
technically, shouldn't see parameter in url since you're using post method (get pass them through url). try switching if want in url. also, try putting data object instead of string, e.g.
data: { "followup": selectedoption },
let me know if hits, if have questions :)
Comments
Post a Comment