在我的 php 文件中,javascript/html 代码是使用 echo 编写的。我想访问将要放置在 javascript 中“place1”div 中的图像并将其传递给 php。
这是我的代码:
// create a placeholder for an image- user is going to drag and drop an image here
echo "<div id= 'place1' class = 'place'></div>";
echo '<button id="apply" name="save" type="submit">Apply Changes</button>';
echo '<script src="http://code.jquery.com/jquery-1.9.1.js"></script>';
//javascipt code to find the source of that image
echo
'<script>
$(document).ready(function(){
$("#apply").click(function() {
var frame = $("#place1").children("img").attr("src");
$.ajax({
url: "thumbnails.php",
type: "POST",
data: frame
});
});
});
</script>';
// access frame variable (image source) in php ??? not sure how to do this part..
$frame = $_post['frame'];