调用asmx生成itexsharp pdf后,Ajax失败/错误

时间:2016-05-03 05:20:02

标签: javascript c# asmx

我有外部javascript invoice.js,它调用asmx服务如下生成并保存invoice.pdf

$.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "/CommonService.asmx/GenerateInvoice",
            data: "{}",
            dataType: "json",
            success: function (response) {
               alert('Success');
            },
            error: function (response) {
                alert('error');
            }
        }).done(function () {//this will execute after completing ajax call also u can pass the same response to this method

            var dXmlhttp;


            var colUrl = /Service.svc/json/somefunction";
            var columnData = {
                "objList": {
                    "Mappingid": mappingid,
                    "JsonArray": JsonInvoiceArray


                }
            };
            var parmColum = JSON.stringify(columnData);

            if (window.XMLHttpRequest) {
                // code for IE7+, Firefox, Chrome, Opera, Safari
                colHttp = new XMLHttpRequest();
            }
            else {
                // code for IE6, IE5
                colHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            colHttp.onreadystatechange = function () {
                if (colHttp.readyState == 4 && colHttp.status == 200) {
                    var result = JSON.parse(colHttp.responseText);

                    }
                }
            }
            colHttp.open("POST", colUrl, true);
            colHttp.setRequestHeader("Content-type", "application/json");
            colHttp.send(parmColum);
        });

在Itextsharp中,pdf生成代码将始终运行alert('error');,并且它不会调用done()。 GenerateInvoice调用asmx来创建pdf,它将保存pdf。

0 个答案:

没有答案