问题就在于此
$('<td></td>').val(item['id']).html( '<a href="edit.html?id'='+sid'">Edit</a>'),alert(sid+"Id2:"+item['id']),这里的警报很清楚..但是在浏览器中显示路径
//localhost:8080/sample/teacher/edit.html?id'=sid”
这里没有显示sid的值,即id 41我希望将链接显示为
localhost:8080 / sample / teacher / edit.html?id = 41或任何其他动态id值
我不知道为什么这会发生代码不对
这里var sid是一个数组和推送值id到数组..警报正确显示sid&item ['id']的值。
$.each(responseData, function(index, item) { var sid = []; $('#student').append( $('<td></td>').val(item['id']).html( item['name']), $('<td></td>').val(item['id']).html( item['phoneNo']), sid.push(item['id']), $('&t;td></td>').val(item['id']).html( '<a href="edit.html?id'='+sid'">Edit</a>'),alert(sid+"Id2:"+item['id']), $('<td></td>').val(item['id']).html( '<button onclick="lightbox1_open();">Delete</button>'), $('<br />').val(item['id']).html( item[''])); });如果你知道答案,请在这里分享......
the problem was in the line
$('<td></td>').val(item['id']).html( '<a href="edit.html?id'='+sid'">Edit</a>'),alert(sid+"Id2:"+item['id']),here the alert is getting clearly.. but in browser the path shows
//localhost:8080/sample/teacher/edit.html?id'=sid'
here not shows the value of sid that is id 41 i want to show the link as
localhost:8080/sample/teacher/edit.html?id=41 or any other dynamic id value
i don't know why this happen the code is not right
Here var sid is an array & push value id to array.. the alert shows the value of sid & item['id'] correctly.
$.each(responseData, function(index, item) { var sid = []; $('#student').append( $('<td></td>').val(item['id']).html( item['name']), $('<td></td>').val(item['id']).html( item['phoneNo']), sid.push(item['id']), $('<td></td>').val(item['id']).html( '<a href="edit.html?id'='+sid'">Edit</a>'),alert(sid+"Id2:"+item['id']), $('<td></td>').val(item['id']).html( '<button onclick="lightbox1_open();">Delete</button>'), $('<br />').val(item['id']).html( item[''])); });if you know the answer please share here...
最满意答案
看起来字符串连接是问题,试试
$('<td></td>').val(item['id']).html('<a href="edit.html?id=' + sid + '">Edit</a>')Looks like the string concatenation is the problem, try
$('<td></td>').val(item['id']).html('<a href="edit.html?id=' + sid + '">Edit</a>')更多推荐
item,sid,'id',html,电脑培训,计算机培训,IT培训"/> <meta name="
发布评论