Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过javascript函数将元素id传递给xajax php函数_Php_Javascript_Xajax - Fatal编程技术网

通过javascript函数将元素id传递给xajax php函数

通过javascript函数将元素id传递给xajax php函数,php,javascript,xajax,Php,Javascript,Xajax,我正在使用xajax函数检查用户名的可用性,我希望它出现在anchar标记单击上。我这样做就像onclick=“xajax\u checkusername('getElementByid(\'username\”).value')。但它不起作用。请在您的示例中使用帮助 getElementByid(\"username\").value 应该是 document.getElementById("username").value // id should be ID 如果错误地传递了参数,请删

我正在使用xajax函数检查用户名的可用性,我希望它出现在anchar标记单击上。我这样做就像
onclick=“xajax\u checkusername('getElementByid(\'username\”).value')
。但它不起作用。请在您的示例中使用帮助

getElementByid(\"username\").value
应该是

document.getElementById("username").value // id should be ID

如果错误地传递了参数,请删除单引号,使其成为

onclick="xajax_checkusername(document.getElementByid('username').value)"
请注意,不建议使用这种内联Javascript,因为它将成为维护的噩梦

请使用

onclick=“xajax_checkusername(xajax.$('username').value);"

用户名字段ID标记值必须为“用户名” e、 g

尝试使用此

onclick=\"xajax_checkusername(getElementById('username').value))\";

onclick=“xajax\u checkusername('getElementByid(\'username\').value')”我在按钮上调用它,比如说。checkusername($username)是php函数onclick=“xajax\u checkusername('document.getElementByid(\'username\').value'))“这也不起作用
\'username\'
应该是
'username'
。如果通过其他方式传递“不起作用”的信息不足,您的控制台中是否看到任何错误?”?F12Username:请用代码更新您的问题,注释并非针对整段代码