Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php $.post()函数不起作用?_Php_Javascript_Jquery_Mysql - Fatal编程技术网

Php $.post()函数不起作用?

Php $.post()函数不起作用?,php,javascript,jquery,mysql,Php,Javascript,Jquery,Mysql,我日日夜夜试图找到一个解决办法。没什么 我知道$.post是如何工作的,但由于某种原因,它就是不工作 这就是我想做的 将post函数调用到一个PHP页面,该页面查询MySQL的值(无需输入) 将设置为该值 有什么建议吗?非常感谢 function refresh() { $.post("check.php",change(data)); } function change(text) { getElementbyId('money').innerHTML=text; } 绝对不是post的工

我日日夜夜试图找到一个解决办法。没什么

我知道
$.post
是如何工作的,但由于某种原因,它就是不工作

这就是我想做的

  • 将post函数调用到一个PHP页面,该页面查询MySQL的值(无需输入)
  • 设置为该值
  • 有什么建议吗?非常感谢

    function refresh()
    {
    $.post("check.php",change(data));
    }
    
    function change(text)
    {
    getElementbyId('money').innerHTML=text;
    }
    

    绝对不是post的工作方式

    $.post("check.php", change);
    
    
    function change(text)
    {
       document.getElementById('money').innerHTML = text;
    }
    

    这只是一个快速完成的代码,但是这个呢

    function change(text)
    {
    document.getElementbyId('money').innerHTML=text;
    }
    
    
    $.post('check.php', change);
    
    或者更简单地说

    $.post("check.php",change);
    

    在设置ajax调用时,您不想调用change函数。要将回调函数传递给
    $.post()

    如果使用处理程序函数,则需要省略参数并仅提供处理程序函数名,或者将处理程序函数与参数包装在匿名函数中

    $.post("check.php",change);
    


    调用getElementById而不调用“文档”时出错,应使用:

    document.getElementById("money").innerHTML=text;
    
    或者(如果使用jQuery)

    请尝试以下代码:

    function refresh()
    {
       $.post('check.php', function(data) {
         $("#money").html(data);
       });
    }
    
    refresh();
    
    试试这个(在中测试):


    显示一些您迄今为止尝试过的代码。@DylanCross从问题正文中可以明显看出。我知道他试图做什么,但我想知道他尝试过什么代码。您是如何使用
    $的。post
    ,什么不完全有效?@user1292810:您刚才的编辑远远不够。例如,您如何调用
    刷新
    ?或者简单的
    $.post(“check.php”,change)
    。所以我需要这样称呼它?您还需要
    document.getElementbyId
    @AlexWayne并修复语法错误:
    document.getElementbyId
    。好的,在我的php页面上,我回显了mysql\U查询的结果。
    $("#money").html(text_value);
    
    function refresh()
    {
       $.post('check.php', function(data) {
         $("#money").html(data);
       });
    }
    
    refresh();
    
        function refresh()
        {    
             $.ajax({
                  //replace your url
                  url: '/echo/html/',
                  type: 'POST',
                  // you can delete "data" parameter if not needed
                  // is only for testing ajax on jsfiddle addording to the documentation
                  // http://doc.jsfiddle.net/use/echo.html
                  data: {
                        html: "Test ajax"
                  },
             }).done(function ( data ) {
                  $("#money").html(data);
             });
        }
    
    
        $(document).ready(function() {
             refresh();
        });