我有以下代码:jQuery .html()的回调函数?
$.ajax({
type: 'GET',
url: 'index.php?route=checkout/onepagecheckout/getpaypaldata',
dataType: 'json',
success: function(json) {
$('#pp_info').html(json['output']);
$('#payment').submit();
}
});
Ajax请求接收包含一个HTML形式等JSON对象:
<form id="payment" method="post" action="https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" value="_cart" name="cmd">
<input type="hidden" value="1" name="upload">
<input type="hidden" value="[email protected]" name="business">
<input type="hidden" value="Sample Item Name" name="item_name_1">
<input type="hidden" value="TESTI-1" name="item_number_1">
<input type="hidden" value="104.98" name="amount_1">
<input type="hidden" value="1" name="quantity_1">
<input type="hidden" value="0" name="weight_1">
<input type="hidden" value="Type" name="on0_1">
<input type="hidden" value="As Shown" name="os0_1">
<input type="hidden" value="Delivery Date" name="on1_1">
<input type="hidden" value="Jun 23,2012" name="os1_1">
<input type="hidden" value="Comments" name="on3_1">
<input type="hidden" value="test message" name="os3_1">
</form>
其中包含贝需要以处理订单的信息。一切正常,除了我相信有时表单会在jQuery .html函数加载html内容之前被提交。
有.html的任何回调函数吗?或者我可以用来解决问题的其他方法? PayPal数据以HTML形式出现,我无法更改该部分,所以我只有一个选项可以加载html内容并提交表单!
首先响应的是不是一个JSON。这是HTML回应,请检查您的代码。 –
.html方法应该是同步的。正如UmeshA指出的那样,你的问题可能是另一回事。 – hugomg
它是json,唯一的事情就是将html内容作为字符串存储在jsonp ['output']中。 json对象也包含一些其他信息。 – Tohid