如何在AJAX中检索选择器的值并将其保存在PHP中?

问题描述 投票:0回答:1

我有prop()方法,想在php中检索“ show_pdf1”并在返回readPdf.php的最终结果之前在其中保存值以进行处理。如何在不使用其他方法但使用属性方法的情况下执行此操作?

$('#show_pdf1').prop('src', 'php/readPdf.php');

在php中,我想另存为

$value = 'show_pdf1'; //retrieve the selector here

php ajax selector
1个回答
0
投票
$.post('php/readPdf.php', {whichFrame:whichFrame,value:value},
function(data) {
  $('#'+whichFrame+'').prop('src', data);
});

whichFrame和value是javascript方法,您可以通过id从不同的标记中获取值。

我的readPdf.php返回文件。

<?php
echo $file1; //this get set as data as a 'src' attribute.
?>

就这样,还是谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.