大岭山小程序定做_js完成简易谈天对话框

2021-01-11

js实现简易聊天对话框       这篇文章主要为大家详细介绍了js实现简易聊天对话框,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
var input = document.getElementById('msg_input');//查找缓存 document.getElementById('sendbtn'). unction () { //var input1 = document.getElementById('msg_input');// //input0 sendMsg();
var input = document.getElementById('msg_input');//查找缓存 var ul = document.getElementById('content'); var newLi = document.createElement('li'); newLi.innerHTML = input.value; newLi.className = 'msgContent right'; ul.appendChild(newLi); var div = document.createElement('div'); div.style = 'clear:both'; ul.appendChild(div);
url:'iqa/query question='+input.value, success:function (res) { // console.log(res) var obj = JSON.parse(res); console.log(obj) var array = obj.result.content; // var zhengzhou = array[0]; var tmp = array; // var tmp = '温度:'+zhengzhou.day_air_temperature+','+zhengzhou.day_weather; console.log(tmp) var newLi = document.createElement('li'); newLi.innerHTML = tmp; newLi.className = 'msgContent left'; ul.appendChild(newLi); var div = document.createElement('div'); div.style = 'clear:both'; ul.appendChild(div); input.value = ''; newLi.scrollIntoView();//将元素滚动到可见位置 input.value = ''; newLi.scrollIntoView();//将元素滚动到可见位置
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xhr.setRequestHeader("Authorization","APPCODE 3e9dfb924f464e9593a95f9d2bbf4348")
// var sendData = 'username=zhangsan password=123456'; if( obj.method == undefined ||obj.method.toLowerCase() =='get'){ xhr.send(null);// }else{ xhr.send(obj.params);//


扫描二维码分享到微信

在线咨询
联系电话

400-888-8866