<legend id='TlECK'><style id='TlECK'><dir id='TlECK'><q id='TlECK'></q></dir></style></legend>

    1. <small id='TlECK'></small><noframes id='TlECK'>

      • <bdo id='TlECK'></bdo><ul id='TlECK'></ul>
      <tfoot id='TlECK'></tfoot>
      <i id='TlECK'><tr id='TlECK'><dt id='TlECK'><q id='TlECK'><span id='TlECK'><b id='TlECK'><form id='TlECK'><ins id='TlECK'></ins><ul id='TlECK'></ul><sub id='TlECK'></sub></form><legend id='TlECK'></legend><bdo id='TlECK'><pre id='TlECK'><center id='TlECK'></center></pre></bdo></b><th id='TlECK'></th></span></q></dt></tr></i><div id='TlECK'><tfoot id='TlECK'></tfoot><dl id='TlECK'><fieldset id='TlECK'></fieldset></dl></div>

        只定义了函数,但无论如何都会立即执行

        Function only defined but immediately executed anyway(只定义了函数,但无论如何都会立即执行)

            <legend id='0d6uq'><style id='0d6uq'><dir id='0d6uq'><q id='0d6uq'></q></dir></style></legend>
          1. <i id='0d6uq'><tr id='0d6uq'><dt id='0d6uq'><q id='0d6uq'><span id='0d6uq'><b id='0d6uq'><form id='0d6uq'><ins id='0d6uq'></ins><ul id='0d6uq'></ul><sub id='0d6uq'></sub></form><legend id='0d6uq'></legend><bdo id='0d6uq'><pre id='0d6uq'><center id='0d6uq'></center></pre></bdo></b><th id='0d6uq'></th></span></q></dt></tr></i><div id='0d6uq'><tfoot id='0d6uq'></tfoot><dl id='0d6uq'><fieldset id='0d6uq'></fieldset></dl></div>
              <tfoot id='0d6uq'></tfoot>

                <bdo id='0d6uq'></bdo><ul id='0d6uq'></ul>
              • <small id='0d6uq'></small><noframes id='0d6uq'>

                    <tbody id='0d6uq'></tbody>

                  本文介绍了只定义了函数,但无论如何都会立即执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的文件 ajaxrequest.js 中有一段简短的 javascript 代码有问题.这里是:

                  I'm having trouble with a short javascript code in my file ajaxrequest.js . Here it is :

                  function afficher () {
                    $.post('requete_affichage.php', function (data) {
                      $('#name-data').text(data); });
                  }
                  
                  $('#bouton2').on('click', afficher());
                  

                  所以问题是,只要我在浏览器中点击localhost",该函数就会立即执行并将数据插入到我的 index.html 页面的 div#name-data 字段中,而不是等待我点击#bouton2 这样做.有什么想法吗?

                  So the problem is the function immediately executes and inserts the data in the div#name-data field of my index.html page as soon as i hit "localhost" in my browser, and doesn't wait for my click on #bouton2 to do so. Any idea ?

                  推荐答案

                  通过在函数后面加上方括号,您可以告诉它立即执行.要将函数引用分配给单击处理程序,请删除括号:

                  By including the brackets after the function you are telling it to execute immediately. To assign the function reference to the click handler, remove the brackets:

                  $('#bouton2').on('click', afficher);
                  

                  这篇关于只定义了函数,但无论如何都会立即执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  PHP Upload File Validation(PHP 上传文件验证)
                  PHP Error - Uploading a file(PHP 错误 - 上传文件)
                  How can I write tests for file upload in PHP?(如何在 PHP 中编写文件上传测试?)
                  php resizing image on upload rotates the image when i don#39;t want it to(php在上传时调整图像大小会在我不想要它时旋转图像)
                  How to send additional data using PLupload?(如何使用 PLupload 发送附加数据?)
                  change button text in js/ajax after mp4 =gt;mp3 conversion in php(在 php 中的 mp4 =gt;mp3 转换后更改 js/ajax 中的按钮文本)

                    <tfoot id='KafIO'></tfoot>
                    1. <i id='KafIO'><tr id='KafIO'><dt id='KafIO'><q id='KafIO'><span id='KafIO'><b id='KafIO'><form id='KafIO'><ins id='KafIO'></ins><ul id='KafIO'></ul><sub id='KafIO'></sub></form><legend id='KafIO'></legend><bdo id='KafIO'><pre id='KafIO'><center id='KafIO'></center></pre></bdo></b><th id='KafIO'></th></span></q></dt></tr></i><div id='KafIO'><tfoot id='KafIO'></tfoot><dl id='KafIO'><fieldset id='KafIO'></fieldset></dl></div>

                          <bdo id='KafIO'></bdo><ul id='KafIO'></ul>

                          <small id='KafIO'></small><noframes id='KafIO'>

                            <tbody id='KafIO'></tbody>

                            <legend id='KafIO'><style id='KafIO'><dir id='KafIO'><q id='KafIO'></q></dir></style></legend>