Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.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中的acess变量url_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript ajax中的acess变量url

Javascript ajax中的acess变量url,javascript,jquery,ajax,Javascript,Jquery,Ajax,伙计们,我正在尝试创建一个变量url来将它传递给ajax调用。我知道它是虚拟的,但我找不到解决方案,它不起作用。。这是我的密码 函数网格库(文件名){ this.fileName=文件名; } GridLibrary.prototype={ set_fileName:函数(文件名){ this.fileName=文件名; }, 获取文件名:函数(){ 返回此文件名; } }; GridLibrary.prototype.display=函数(){ $.ajax({ url:get_fileNa

伙计们,我正在尝试创建一个变量url来将它传递给ajax调用。我知道它是虚拟的,但我找不到解决方案,它不起作用。。这是我的密码

函数网格库(文件名){
this.fileName=文件名;
}
GridLibrary.prototype={
set_fileName:函数(文件名){
this.fileName=文件名;
},
获取文件名:函数(){
返回此文件名;
}
};
GridLibrary.prototype.display=函数(){
$.ajax({
url:get_fileName(),
错误:函数(即,e){
控制台日志(e);
},
成功:功能(数据){
var表=”;
$.each(数据、函数(索引、MyList){
表+=''+MyList.id+''+MyList.name
+''+MyList.age+''
+MyList.feedback+“”;
});
表+='';
$('body')。追加(表);
}
});
};
get_fileName()
不是函数,因为它是
GridLibrary.prototype


您必须使用
this.get_fileName()

您可以从外部源加载URL,这不是您的问题

使用“this”关键字修复您的问题

url : this.get_fileName()

你能详细解释一下“它不起作用”是什么意思吗?你的控制台说什么?
get\u fileName()
返回什么?它告诉我get\u fileName()不是函数。。。get\u fileName()返回此文件名。我要做的就是从外部源传递url尝试将
url:get\u fileName()
更改为
url:this.get\u fileName()