通过JQUERY将元素id传递给php [英] passing element id to php through JQUERY
本文介绍了通过JQUERY将元素id传递给php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过JQuery将html元素id(实际上从td)传递到php页面。我正在使用的JQuery函数是:
$( document )。ready( function (){
$( td)。click( function (){
alert($( this )。attr( ' id'));
$ .post( index.php?p = lesson,{id:$( this ).attr(' id')}, function (回复){
alert(response);
});
});
})
和php页面中的调用:
$ lessonPath = $ _ POST [' id'];
,但我传递php页面中的值的变量根本没有得到任何值。
有什么想法吗?
解决方案
< blockquote>( document )。ready( function (){
( td)。click( function (){
alert(
( this )。attr(' id'));
I'm trying pass a html element id (from a td actually) through JQuery to a php page. The JQuery function i'm using is:
$(document).ready(function(){
$("td").click(function () {
alert($(this).attr('id'));
$.post("index.php?p=lesson", { id: $(this).attr('id') }, function (response) {
alert(response);
});
});
})
and the call in the php page:
$lessonPath=$_POST['id'];
but the variable i'm passing the the value in php page doesnt get a value at all.
Any ideas?
解决方案
(document).ready(function(){
("td").click(function () { alert(
(this).attr('id'));
这篇关于通过JQUERY将元素id传递给php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文