weixin_33717298 2015-12-28 21:41 采纳率: 0%
浏览 20

Ajax调用和卷曲问题

I have an AJAX script that do call a PHP script which uses CURL to send a request to webservice and saves the response in a text file.

The codes are as following :

Javascript:

$(document).ready(function(){
                $("#doCall").click(function(){
                    $.ajax({
                        cache : false,
                        type : 'POST',
                        url : 'test.php',
                        success : function (response) {
                            console.log(response);
                        },
                        error : function () {
                            console.log("Server side error, try later!");
                        }
                    });      
                }); 
            });

PHP

<?php
$data = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws">
 <soapenv:Header/>
   <soapenv:Body> <ws:uploadCSRP soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
                                             <email xsi:type="xsd:string">myemail@email.com</email>
                                             <pw xsi:type="xsd:string">pass123</pw>
                                             <pid xsi:type="xsd:string">111</pid>
                                             <buildID xsi:type="xsd:string">1.0</buildID>
                                            <fileDataType xsi:type="xsd:string">S</fileDataType>
                                            <fileToUpload xsi:type="xsd:string"><![CDATA[10038|Dickson Motor Service, Inc.|Dickson Motor Service, Inc.|SS4u@att.net|*
10040|Ramus Companies, Inc.|Ramus Companies|DD@gmail.com|*
]]></fileToUpload>
</ws:uploadCSRP> </soapenv:Body></soapenv:Envelope>
';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "MyURL"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60000);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch,CURLOPT_HTTPHEADER, array("Content-Type: text/xml;charset=UTF-8", "SoapAction: *"));
$content = trim(curl_exec($ch));
curl_close($ch);
$myfile = fopen("response.txt", "w") or die("Unable to open file!");
fwrite($myfile, $content);
fclose($myfile);
echo done;

The issue I'm facing is as following:

when the data variable contains a few entries all is working fine the response is saved in the file and "done" is printed in the browser's console however when I put 10000 entries in the data variable the ajax call never ends and when I check the response.txt file I see that the server sent the response and that it was saved in the file so my question is: is there a timeout issue with ajax or curl in my code that happens when to much data is sent?

Thanks.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
    • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
    • ¥15 网络设备配置与管理这个该怎么弄
    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码