从javascript调用Php Web服务

Php webservice calling from javascript

本文关键字:Web 服务 Php 调用 javascript      更新时间:2023-09-26

我正在尝试调用一个web服务,该服务具有来自JavaScript的Json输出。但我无法获得价值。我尝试了不同的方法,但都没有成功。请帮忙!!

这是我试过的代码

  <script src="jquery-1.3.2.min.js"></script>
  <script type="text/javascript">
     function callajax(){ 
    var html =$.ajax({
       cache: false,
       type: "GET",
       async: false,`enter code here`
       data: {},
       url: "http://domain/abc.php?param=abcd',
       contentType: "application/json; charset=utf-8",
       dataType: "json",
       crossDomain: true,
       Success: SucceedFunc,`enter code here`
       error: function (request, errorText, errorCode) 
       {
         alert(errorText+"--"+errorCode);
       }
     });      
   }   
   function SucceedFunc(data, status) 
   {
    alert("Enter into Success");
    alert(data);
   }

所需输出的格式为{"name":Alex,"Success":true}。我需要为"name"选择值。

我们将不胜感激。

是因为您的Success:是大写的吗?应为success:

编辑:

另外,您使用这么旧版本的jQuery是有原因的吗?它们现在的价格是1.9.x(大多数用途)。我只是查了一下,在1.5中添加了crossDomain选项。