PHP / AJAX将表单输入和选择值传递给AJAX

时间:2016-04-08 22:55:42

标签: php jquery ajax

我有一个HTML表单,它基本上包含一个输入文本框和一个选择...

输入框

echo '<input type="input" id="category_typex" name="category_typex" value="" />';

选择

echo '<select name="primary_cat" id="primary_cat" onChange="getSecondaryCat(this.value);">';

我用来传递select的Ajax代码如下:

function getSecondaryCat(val, cat_var) {
$.ajax({
    type: "POST",
    url: "category-get-secondary.php",
    data:'secondary_cat='+val,
    success: function(data){
        $("#secondary_cat").html(data);
        $("#tertiary_cat").html('<option value="">Select specific category</option>')
    }
});
}

我无法将选择和输入值都传递到下一页....

我只能传递选择值而不能传递输入值

1 个答案:

答案 0 :(得分:1)

试试这个:

SELECT u.email, c.uid
FROM (SELECT CASE
                WHEN from_user_id = '301' THEN to_user_id
                ELSE from_user_id
             END AS uid
      FROM contacts
      WHERE from_user_id = '301' OR to_user_id = '301') AS c'
LEFT JOIN users AS u
ON u.id = c.uid