不使用flexigrid的URL字段没有来自URL的响应

时间:2012-12-27 06:23:11

标签: json jquery flexigrid

当我传递URL时,我收到了来自url的无响应,否则,如果我指定了包含在我的项目中的相应WCF服务页面,它是否正常工作是否是任何跨域问题可能出现的问题

<form id="sform" runat="server">
     <table id="flex2" style="display:none"></table>  
     <script type="text/javascript">
      $(document).ready(function () {
            var user_id = 1;
            var data = { UserID: user_id };

        $("#flex2").flexigrid({

            useInlineEditor: true,
            //singleSelect: true,
            rowClick: function (row) {
                //var r=this.DataSource.rows[row.rowIndex];
                //var p=$(row).offset();
                //alert(r[this.DataSource.key]+"   "+r.Name+" offset:"+p.top+","+p.left);
                //this.grid.inlineEditor.edit(row);
            },

            url: 'http://192.168.10.91:5001/Service.svc/GetStates',
            method: 'POST',
            dataType: 'json',
            colModel: [
            { display: 'Hours', name: 'hours', width: 40, sortable: true, align: 'center' },
            { display: 'DOC', name: 'doc', width: 180, sortable: true, align: 'left' },
            ],
            searchitems: [
            { display: 'Type', name: 'cmetype' }
            ],
            onError: function (jqXHR, textStatus, errorThrown) {
                alert("flexigrid failed " + errorThrown  + jqXHR + textStatus);
            },
            sortname: "type",
            sortorder: "asc",
            usepager: true,
            title: 'States',
            useRp: true,
            rp: 15,
            showTableToggleBtn: true,
            width: 800,
            height: 200
        });
    });

    //This function adds paramaters to the post of flexigrid. You can add a verification as well by return to false if you don't want flexigrid to submit           
    function addFormData() {
        //passing a form object to serializeArray will get the valid data from all the objects, but, if the you pass a non-form object, you have to specify the input elements that the data will come from
        var dt = $('#sform').serializeArray();
        $("#flex2").flexOptions({ params: dt });
        return true;
    }

    $('#sform').submit(function () {
        $('#flex2').flexOptions({ newp: 1 }).flexReload();
        return false;
    });
</script>
</form>

1 个答案:

答案 0 :(得分:0)

确保svc服务是accessibile并且它可以接受发布请求。 如果一切正常,请检查响应是否为JSON且有效。