我有一个 php 聊天页面,其中包含群聊和一对一聊天。我在更改事件上使用 jquery 从 php 文件上传函数获取数据,并将图像 HTML 文本输入到 contenteditable div 中,以便也可以和文本。
这在群聊窗口中工作正常,但在单个聊天窗口中无效。两个聊天窗口代码都在同一个 html 中,js 样式块隐藏了显示。一切正常,除了 on change 是行不通的,不管我做什么。
我知道在我的代码片段中我仍然需要处理目标,因为这是动态的,但是一旦 on change 事件实际触发,这应该足够简单。
这是表单位,它是在 js/php 函数中构建的,这是唯一一个不起作用的 ''''''''''''''''''''''''
modal_content += '<form id="uploadImagesc" method="post" action="php_includes/chat-img-upload-sc.php">';
modal_content += '<label for="uploadFilesc"><i class="fas fa-cloud-upload-alt"></i></label>';
modal_content += '<input type="file" name="uploadFilesc" id="uploadFilesc" accept=".jpg, .png" /></form>';
''''''''''''''''''''''''''''''''''''''
这是来自群聊的例子,它正在工作 '''''''''''''''''''''''''''''''''''''
<form id="uploadImage" method="post" action="php_includes/chat-img-upload.php">
<label for="uploadFile"><i class="fas fa-cloud-upload-alt"></i></label>
<input type="file" name="uploadFile" id="uploadFile" accept=".jpg, .png" />
</form>
'''''''''''''''''''''''''''''''''''',这些都在。更改 JQuery 的位
''''''''''''''''''''''''''''''''''''''''''' 工作代码
$('#uploadFile').on('change', function(){
'$'('#uploadImage').ajaxSubmit({
target: "#group_chat_message",
resetForm: true
});
});
'''''''''''''''''''''''
不工作的代码
$('#uploadFilesc').on('change', function(){
// var to_user_id = $(this).attr('id');
// var chat_message = '#chat_message_'+to_user_id;
$('#uploadImagesc').ajaxSubmit({
target: chat_message,
resetForm: true
});
});
所以在这一点上,它只是让第二个函数调用从 Php 获取数据的 on change 函数,我会很高兴此刻 onchange 的警报。
呼啦一阵风
阿波罗的战车
吃鸡游戏
相关分类