【发布时间】:2016-08-12 04:19:56
【问题描述】:
我正在尝试从这个 json javascript 代码中获取一些数据并使用 CURL 将它们打印到 PHP
<html>
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<body>
<script type="text/javascript">
jQuery.ajax(
{
type:"POST",
contentType:"application/json;charset=utf-8",
url:"https://www.bancopromerica.com.gt/wsservicebus/wsonlineservicebus.asmx/getTipoCambio",
data:"{}",
dataType:"json",
async: false,
success: function(msg) {
a("#compInter",msg.d.compraInternet); //Compra Internacional
a("#ventInter",msg.d.ventaInternet); //Venta Internacional
a("#compAgencia",msg.d.compraAgencia); //Compra Agencia
a("#ventAgencia",msg.d.ventaAgencia); //Venta Agencia
},
error: function(textStatus, errorThrown, errorDetail){
alert(errorDetail);
}
});
function a(a,b)
{
jQuery(a).append(b);
}
</script>
</body>
</html>
我收到此错误:
[异常...“失败”nsresult:“0x80004005 (NS_ERROR_FAILURE)” 位置:“JS框架::http://code.jquery.com/jquery-1.12.0.min.js:: .send :: line 4" 数据:无]
您知道如何在 PHP 中正确执行此操作吗?
【问题讨论】:
-
您有一个
div和一个id的compInter。这将附加值msg.d.compraInternet。这不工作吗? -
PHP 与此有什么关系?您有一些 JavaScript 和一个指向 ASP.NET Web 服务的 URL。
-
@steve 不,我有一个错误..
-
@Quentin 我需要使用 CURL,ASP.net 只是一个例子,它可以很好地与 web 服务一起工作,但我需要让它与 PHP 一起工作
-
@rojocuarentaodiso — 你是在问如何用 PHP/cURL 代替 JavaScript 来做你目前正在做的事情吗?
标签: javascript php json curl