Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.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页面发送调用_Php_Jquery_Mysql_Ajax - Fatal编程技术网

脚本函数如何向php页面发送调用

脚本函数如何向php页面发送调用,php,jquery,mysql,ajax,Php,Jquery,Mysql,Ajax,基本上,我希望在我的HTML/PHP页面上有一个按钮,一旦单击该按钮,将向另一个PHP页面发送一个调用,该页面将更新mysql表中的一个值 <html> <head> <script> src = "https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"> function toggleText(button_id){

基本上,我希望在我的HTML/PHP页面上有一个按钮,一旦单击该按钮,将向另一个PHP页面发送一个调用,该页面将更新mysql表中的一个值

    <html>
    <head>
    <script>
    src = "https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
    function toggleText(button_id){
            if(document.getElementById(button_id).innerHTML == "Uninstall All"){
                    document.getElementById(button_id).innerHTML = "Cancel Uninstall";
                    //ajax////////////////////
                    xmlhttp = new XMLHttpRequest();
                    xmlhttp.open("GET", "valueChange.php?uninstalled=1&type=all", true);
                    xmlhttp.send();
                    ////////////////////////
            }
 }
    </script>
    </head>

src=”https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
功能切换文本(按钮id){
if(document.getElementById(按钮id).innerHTML==“全部卸载”){
document.getElementById(按钮id).innerHTML=“取消卸载”;
//阿贾克斯////////////////////
xmlhttp=新的XMLHttpRequest();
open(“GET”,“valueChange.php?uninstalled=1&type=all”,true);
xmlhttp.send();
////////////////////////
}
}
我很好奇为什么这不起作用

我在没有ajax的情况下测试了toggleText函数,它正确地更改了HTML

但是,一旦我添加ajax来访问这个valueChange.php页面并更新sql值,它就不起作用了

我已经单独测试了php页面,它正确地更新了sql中的值


我从未使用过ajax,所以我很好奇我是否做错了?我认为我的src=“google/ajax/jquery”是安装它的方式。或者我需要在承载我的站点的VPS上安装一个库吗?

我在上述代码中看到的唯一错误只是一个输入错误。请参见第3行,您在第二个属性之前关闭了脚本标记,该属性应该是

还有一件事,使用
XMLHttpRequest()
方法不需要使用jQuery库

修改后的代码:


功能切换文本(按钮id)
{
if(document.getElementById(按钮id).innerHTML==“全部卸载”)
{
document.getElementById(按钮id).innerHTML=“取消卸载”;
//阿贾克斯////////////////////
var xmlhttp=new XMLHttpRequest();
open(“GET”,“valueChange.php?uninstalled=1&type=all”,true);
xmlhttp.send();
////////////////////////
}
}

我在上述代码中看到的唯一错误就是打字错误。请参见第3行,您在第二个属性之前关闭了脚本标记,该属性应该是

还有一件事,使用
XMLHttpRequest()
方法不需要使用jQuery库

修改后的代码:


功能切换文本(按钮id)
{
if(document.getElementById(按钮id).innerHTML==“全部卸载”)
{
document.getElementById(按钮id).innerHTML=“取消卸载”;
//阿贾克斯////////////////////
var xmlhttp=new XMLHttpRequest();
open(“GET”,“valueChange.php?uninstalled=1&type=all”,true);
xmlhttp.send();
////////////////////////
}
}

什么是ajax代码。我以为xmlhttp对象是ajax?直接从W3学校下载。ajax代码是什么。我以为xmlhttp对象是ajax?直接从W3学校拿到的。
<html>
<head>    
<script>
 function toggleText(button_id)
{
        if(document.getElementById(button_id).innerHTML == "Uninstall All")
            {
                document.getElementById(button_id).innerHTML = "Cancel Uninstall";
                //ajax////////////////////
               var xmlhttp = new XMLHttpRequest();
                xmlhttp.open("GET", "valueChange.php?uninstalled=1&type=all", true);
                xmlhttp.send();
                ////////////////////////
        }
}
</script>
</head>