[英]How do I get a php value in Jquery?
Hey guys I have this populated search form that will bring a table of people based on search result. 大家好,我有这个填充的搜索表单,该表单将根据搜索结果带来一个人表。 I need to be able to get the php variable that has the username I am trying to get, then that will get sent over to .php file using the JQuery UI which will open a notes window. 我需要能够获取具有我要获取的用户名的php变量,然后使用JQuery UI将其发送到.php文件,这将打开一个注释窗口。
So here: 所以在这里:
username, other, other , notes - this is a link and once clicked the following is called: 用户名,其他,其他,注释-这是一个链接,一旦单击,将被称为:
$(document).ready(function () {
$("#NotesAccessor").click(function () {
alert(notes_name);
run();
});
});
which leads to : 这导致 :
function run(){ var url = '/pcg/popups/grabnotes.php'; 函数run(){var url ='/pcg/popups/grabnotes.php'; showUrlInDialog(url); showUrlInDialog(url); } }
to a function that opens the Jquery Dialog. 打开Jquery对话框的函数。
I need to access the username of the based notes that was clicked....if there was 20 results of different names, david, joe, john, etc... I click the notes with david as username, I need that to be sent over to the file that is opening so I can display the based notes on the appropriate username. 我需要访问被单击的基础注释的用户名。...如果有20个不同名称,大卫,乔,约翰等的结果...我单击以大卫作为用户名的注释,我需要发送到正在打开的文件,这样我就可以在相应的用户名上显示基于注释的信息。
Here is my php: 这是我的PHP:
.........
<td>
$csvusername
</td>
.........
<td>
";
if ($checkNotes[1] == 'No')
{
echo "None";
}
if ($checkNotes[1] == 'Yes')
{
echo "<a href='#' id='NotesAccessor'>Click to access</a>";
}
echo "
</td>
........
Let me know if this makes sense to you. 让我知道这对您是否有意义。 I am kinda stuck on this and could use a hand :) 我有点卡在上面,可以用一只手:)
David 大卫
I can't tell what PHP variable you are trying to get, but generally, you can do: 我无法告诉您要获取的PHP变量,但是通常可以做到:
<!-- /myScript.php?myVar=helloWorld -->
<script type="text/javascript">
$(document).ready(function(){
var myPhpVar = <?php echo $_GET['myVar']; ?>;
alert(myPhpVar);
});
</script>
<script>
var x = '<?php echo $variable; ?>';
or
var x = '<?php echo my_function(); ?>';
</script>
<?php
function my_function()
{
return $variable;
}
?>
this should do what you like :) 这应该做你喜欢的事情:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.