weixin_33739646 2020-01-11 19:01 采纳率: 0%
浏览 27

Ajax表单提交被忽略

I am currently working on a project which consists of a chatting website. I have a form(for adding some as a friend through his name) created in javascript and I want to submit it through ajax, but my ajax submission is ignored at all. It is strange because, with a day before it was working correctly, after the submission, I checked the database and everything was fine. The next day, when I woke up and tested again the form it was broken and a URL was displayed in the URLs place :)) despite the fact that I used ajax. I got no response from the database because the submitting function was ignored. What should I do? Here is my project https://github.com/Alex-dev02/letschat the problem is in the main.js file which is attached to index.php. My main.js content:


let mainList = document.createElement("div");
mainList.classList.add("mainList");

let addFriendForm = document.createElement("form");
addFriendForm.id = "FriendForm";
// my ajax submision
$('#FriendForm').submit(function(){
  $.ajax({
    url: '../letschat/Functions/createUserRelation.php',
    type: 'POST'
  });
});

let addFriendField = document.createElement("input");
addFriendField.classList.add("addFriend");
addFriendField.placeholder = "Add a friend";
addFriendField.type = "text";
addFriendField.name = "addFriend";
addFriendField.autocomplete = "off";
addFriendForm.appendChild(addFriendField);

mainList.appendChild(addFriendForm);

body.appendChild(mainList);

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 gojs 点击按钮node的position位置进行改变,再次点击回到原来的位置
    • ¥15 计算决策面并仿真附上结果
    • ¥20 halcon 图像拼接
    • ¥15 webstorm上开发的vue3+vite5+typeScript打包时报错
    • ¥15 vue使用gojs,需求在link中的虚线上添加方向箭头
    • ¥15 CSS通配符清除内外边距为什么可以覆盖默认样式?
    • ¥15 SPSS分类模型实训题步骤
    • ¥100 求ASMedia ASM1184e & ASM1187e 芯片datasheet/规格书
    • ¥15 求解决扩散模型代码问题
    • ¥15 工创大赛太阳能电动车项目零基础要学什么