如何得到$.获取jquery动态参数变量
how to get $.get jquery dynamic argument variable
我试图创建一个Ajax函数调用,其中参数q
将被动态定义,并且$.get
函数将根据Ajax调用返回的数据返回true
或false
。
<a href="any.php" class="idd" id="1">add score</a>
<a href="any.php" class="idd" id="2">add score</a>
<a href="any.php" class="idd" id="3">add score</a>
$(".idd").click(function(event) {
window.Eid=event.target.id;
//alert(window.Eid);
});
$.get("getDetails.php",
{ q: window.Eid }, // I want this variable dynamic
function(m) {
$(".idd").click(function() {
//var Eid=event.target.id;
alert(m);
if(m>0) {
return false;
} else {
return true;
}
});
});
$(function(){
$(".idd").click(function(event) {
var id = this.id;
var ajaxRequest = $.get("getDetails.php", {q: id});
ajaxRequest.done(function(m){
alert(m);
if (m > 0) {
// do sth here
} else {
//do another things here
}
});
ajaxRequest.fail(function(){
alert('failed');
});
return false;
});
});
window.onerror = function(errorMessage, url, line) {
var errorText = 'message: ' + errorMessage + ''nurl: ' + url + ''nline: ' + line;
alert(errorText);
}
相关文章:
- Facebook共享动态参数链接
- 在 angularjs 的 ga 命令中设置动态参数
- JavaScript动态参数
- 在JQGridshowlink格式化程序中添加了动态参数
- 如何使用 javascript 在 HTML 电子邮件中显示动态参数
- 使用动态参数调用函数
- 使用 innerHTML 将动态参数传递给 JavaScript 函数
- Angularjs:隐藏包含动态参数的网址的导航栏
- 解绑,然后将 OnClick 函数(带有动态参数)绑定到 jQuery 或 JavaScript 中继器中的锚标记
- 使用和返回动态参数是否安全
- 创建具有动态参数排列的方法/函数
- 将动态参数应用于 JavaScript 函数,但延迟调用
- ejs :添加动态参数
- 支柱 2 使动态参数
- 具有动态参数长度的函数
- 使用动态参数设置onclick属性
- URL中包含动态参数的快速路由
- 将动态参数传递给IIFE
- Javascript中的动态参数
- Datatables-使用具有多个表和动态参数的Ajax数据源(sAjaxSource)