简体   繁体   English

按提交,没有任何反应(jQuery AJAX表单)

[英]Pressing submit, nothing happens (jQuery AJAX Forms)

Example: dev.alphenweer.nl 示例: dev.alphenweer.nl

When someone clicks on a link, the form gets loaded, they fill out the form, and press a button to submit it. 当某人单击链接时,将加载该表单,然后他们填写该表单,然后按一个按钮来提交。 But when someone presses the button, nothing happends. 但是当有人按下按钮时,什么也没发生。 Why is that? 这是为什么? What is wrong with my code? 我的代码有什么问题?

For example, click on "REQUEST API AGAIN", and then just fill SOMETHING in. Nothing happens. 例如,单击“再次请求API”,然后仅填写内容。什么也没有发生。 Why? 为什么?

You need to use live . 您需要使用live Which will result in 这将导致

$('#api_reg_submit').live('click', function(){...

This happens because the button, which you set click event on, is not in DOM at start aka when its ready, but its added later. 发生这种情况的原因是,您在其上设置了click事件的按钮在启动时(即准备就绪时)不在DOM中,而是在以后添加。 If you had the button outside and loaded only inputs it would work like you have it now. 如果您将按钮放在外面并仅加载输入,则它将像现在一样工作。 Hope it makes sense :) 希望有道理:)

There's no <form> surrounding the input elements, so they're just a random textbox and button sitting on a webpage. 输入元素周围没有<form> ,因此它们只是网页上的随机文本框和按钮。 There's no element with an id of api_req_submit on the page either, so the click function you're trying to add has nowhere to go. 页面上也没有ID为api_req_submit元素,因此您要添加的click函数无处可去。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM