我想读取并为 DIV 分配值,因为它打印在此 Web 服务http://abc.com/new2/app/android/get_product_size.php?productID=113
例如 get_product_size.php 页面可能返回文本或数字。
我也使用了以下代码,问题是当我发出警报时它返回 0 值。我的代码如下
<div class="home%%GLOBAL_ProductId%%"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
var productsize = $('.siz').val();
var id =%%GLOBAL_ProductId%%;
var AllData="" ;
var html="";
//alert(id);
$.ajax({
type: "POST",
url: "http://abc.com/new2/app/android/get_product_size.php?productID="+id,
data: "{Size:'" + productsize + "'}",
//data: {},
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
cache: true,
success: function(msg) {
AjaxSucceeded(msg);
AllData = html.fromhtml(data.d);
$("#home%%GLOBAL_ProductId%%").html(AllData);
//42.toFixed(2);
},
error: AjaxFailed
});
function AjaxSucceeded(result) {
alert(result);
}
function AjaxFailed(result) {
alert(result.status + ' ' + result.statusText);
}
});
</script>