当我按下click here
时,它将是警告空白和空白值。
我想知道为什么不提醒400
和400
test1.php
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<form id="first_image_data_url_fid" style="display: block;">
<input type="text" name="first_image_data_url" id="first_image_data_url"/>
<input type="text" name="first_image_data_dimension_width" id="first_image_data_dimension_width"/>
<input type="text" name="first_image_data_dimension_height" id="first_image_data_dimension_height"/>
</form>
<span id="mySpan_check_image_data_width_height"></span>
<div onclick="test_fn()">click here</div>
<script language="JavaScript" type="text/javascript">
function test_fn()
{
var first_image_data_url = "https://pbs.twimg.com/profile_images/839721704163155970/LI_TRk1z_400x400.jpg";
document.getElementById("first_image_data_url").value = first_image_data_url;
document.getElementById("first_image_data_dimension_width").value = "";
document.getElementById("first_image_data_dimension_height").value = "";
$.ajax
(
{
url: 'test2.php',
type: 'POST',
data: $('#first_image_data_url_fid').serialize(),
cache: false,
success: function (data) {
$('#mySpan_check_image_data_width_height').html(data);
//get_first_image_data_width_height();
}
}
)
var item = get_first_image_data_width_height();
}
</script>
<script>
function get_first_image_data_width_height(){
var item;
var first_image_data_dimension_width_val = document.getElementById("first_image_data_dimension_width").value;
alert(first_image_data_dimension_width_val);
var first_image_data_dimension_height_val = document.getElementById("first_image_data_dimension_height").value;
alert(first_image_data_dimension_height_val);
var item = "0";
return item;
}
</script>
test2.php
<?PHP
session_start();
include("connect.php");
$first_image_data_url = mysqli_real_escape_string($db_mysqli,$_POST['first_image_data_url']);
$first_image_data_dimension = getimagesize($first_image_data_url);
$first_image_data_dimension_width = $first_image_data_dimension[0];
$first_image_data_dimension_height = $first_image_data_dimension[1];
?>
<script>
document.getElementById("first_image_data_dimension_width").value = "<?PHP echo $first_image_data_dimension_width; ?>";
document.getElementById("first_image_data_dimension_height").value = "<?PHP echo $first_image_data_dimension_height; ?>";
</script>