Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.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
Javascript不执行Ajax调用_Javascript_Jquery_Python_Html_Ajax - Fatal编程技术网

Javascript不执行Ajax调用

Javascript不执行Ajax调用,javascript,jquery,python,html,ajax,Javascript,Jquery,Python,Html,Ajax,我有一个在本地主机上运行的HTML页面。我想从Python脚本中访问一些数据,并在HTML页面中使用它,函数中的Ajax调用不起作用,如果我删除它,程序就会运行得很好。有什么帮助吗 Javascript函数: <script src="/js/jquery.min.js" type = "text/javascript" ></script> <link rel="stylesheet" href="LoginStyle.css" type="text/

我有一个在本地主机上运行的HTML页面。我想从Python脚本中访问一些数据,并在HTML页面中使用它,函数中的Ajax调用不起作用,如果我删除它,程序就会运行得很好。有什么帮助吗

Javascript函数:

<script src="/js/jquery.min.js" type = "text/javascript" ></script> 
     <link rel="stylesheet" href="LoginStyle.css" type="text/css" />

 <script type = "text/javascript" >
function getData()
{
//Code doesn't even enter this function but when i remove the $.ajax part it enters the function
alert("I AM HERE");

$.ajax(
{
type: "GET",
url: "/cgi-bin/check.py" // Path of the script/code i want to run
success: function(response)
{
    $("#username").text(data); //this is where i should get the response, Not sure about the syntax i.e. whether i should 
//output in a <div> tag or a text box

}
});
}

url属性中缺少一个

function getData() {
    //Code does not even enter this function but when i remove the $.ajax part it enters the function
    alert("I AM HERE");

    $.ajax({
        type: "GET",
        //--> here missing , in url
        url: "/cgi-bin/check.py", // Path of the script/code i want to run
        success: function (response) {
            $("#username").text(data); //this is where i should get the response, Not sure about the syntax i.e. whether i should 
            //output in a <div> tag or a text box

        }
    });
}
函数getData(){ //代码甚至没有进入这个函数,但是当我删除$.ajax部分时,它就进入了这个函数 警惕(“我在这里”); $.ajax({ 键入:“获取”, //-->这里缺少,在url中 url:“/cgi-bin/check.py”//要运行的脚本/代码的路径 成功:功能(响应){ $(“#username”).text(data);//这是我应该得到响应的地方,但不确定语法,即是否应该 //在标记或文本框中输出 } }); }
尝试使用,您没有添加
url字符串的结尾

url: "/cgi-bin/check.py",
而不是

 url: "/cgi-bin/check.py"

看看控制台……可能有一些syntx错误。这个问题似乎离题了,因为它是关于语法错误POST full stacktrace。我更正了语法错误,但仍然无法从python脚本获得响应,我做得对吗?我在我的错误日志中得到这个“[错误][客户端127.0.0.1]脚本头过早结束:check.py“
url: "/cgi-bin/check.py",
 url: "/cgi-bin/check.py"