How can I pass the two values (filter & $user_id) to Ajax?
PHP:
$user_id = 3;
echo "<select name=\"filter\" data-userid=\"".$user_id."\"
onchange=\"getPoints(this.value)\">
<option value=\"one\">One</option>
<option value=\"two\">Two</option>
</select>";
AJAX:
function getPoints(filter)
{
var userid = $(this).attr('data-userid');
$.ajax({
type: "GET",
url: 'http://website.com?user_id='+userid,
data: '&action='+filter,
success: function(result){
$("#Target").html(result);
}
});
};
I want to get this url:
http://website.com?user_id=3&action=one
I have the problem with passing $user_id to Ajax. Thank you in advance.