Ajax 使用phonegap将照片上载到web服务

Ajax 使用phonegap将照片上载到web服务,ajax,cordova,base64,Ajax,Cordova,Base64,好的,所以我可以用手机的摄像头拍一张照片,并在img中查看,现在我想通过一个接收到视频的web服务上传它 <File> base64Binary </File>. 这就是我试图发送它的方式: var ima=document.getElementById("smallImage").src; var soapRequest ='<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSc

好的,所以我可以用手机的摄像头拍一张照片,并在img中查看,现在我想通过一个接收到视频的web服务上传它

<File> base64Binary </File>.
这就是我试图发送它的方式:

       var ima=document.getElementById("smallImage").src;

       var soapRequest ='<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-          instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+   
            '<soap:Body>'+
            '<InsertFileInfo xmlns="http://tempuri.org/">'+

             '<File>'+ima+'</File>'+
             '<FileName>sldkq.jpg</FileName>'+
             '<Description>Photo</Description>'+
             '<Code>'+CodeFile+'</Code>'+

             '</InsertFileInfo>'+
            '</soap:Body>'+
            '</soap:Envelope>';            

    $.ajax({
                type: "POST",
                url: wsUrl,
                contentType: "text/xml",
                dataType: "xml",
                data: soapRequest,
                success: processSuccess,
                error: processError
            });


    function processSuccess(data, status, req) 
    { 

        if (status == "success")
        {
            alert("sent"); 
        }

    }

    function processError(data, status, req) 
    {
    alert('error'+data.state);
        //alert(req.responseText + " " + status);
    }
然后几分钟过去了,我终于得到processError函数消息


谁能告诉我这有什么问题吗?

我得解决它。如果有人有这个问题:变量'ima'请求img的.src,但这不起作用。所以我使用了其他东西来存储图片的base64值:

window.localStorage.setItem(“CodePhoto”,imageData)

我在请求中读到如下内容:

var codePhoto = window.localStorage.getItem("CodigoFoto");
 ...'<File>'+codePhoto+'</File>'+...
最后把它放进盒子里

 <File></File> 

像这样:

var codePhoto = window.localStorage.getItem("CodigoFoto");
 ...'<File>'+codePhoto+'</File>'+...
…''+codePhoto+''+。。。

什么是错误?我希望定义了
wsUrl
。是的,定义了wsUrl。错误只是说:“function(){return n}”