Home  >  Article  >  Backend Development  >  小弟我用jquery的AJAX通过POST过来数据 appliction/json-rpc 接收不到,这是为什么?

小弟我用jquery的AJAX通过POST过来数据 appliction/json-rpc 接收不到,这是为什么?

WBOY
WBOYOriginal
2016-06-13 10:23:41901browse

我用jquery的AJAX通过POST过来数据 appliction/json-rpc 接收不到,这是为什么??

JScript code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script><script>$.ajax({    type: 'POST',    url: "http://localhost/bubblewitch/index.php/rpc/ClientApi",    data: JSON.stringify("[{2:2},{1:1}]"),    success: function(){},    dataType: "text",    contentType: "application/json-rpc",    timeout:60000,    error: function(){}}); </script>

以上是我的代码,我用POST过来传到服务器,结果我在服务器 $_POST里获取不到
这是为什么??,是不是 application/json-rpc的传输格式导致的,如果这 application/json-rpc传输格式我要怎么在后端获取POST值

------解决方案--------------------
PHP code
$s = fopen("php://input", 'rb');echo fread($s, 10000);<br><font color="#e78608">------解决方案--------------------</font><br>当然有:<br><br>$s = file_get_contents('php://input');<br><br>$s 就是传入的参数<br><br><font color="#e78608">------解决方案--------------------</font><br>因为传输协议不合适<div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn