consume asmx with ajax(outside the webservice layer)

Asked

Viewed 29 times

0

in my Solution I have several layers and one of them is the webservice, all pages that consume the webservice and are in the webservice layer work, but put in another layer of error in javascript.

    <table border="0">
        <tr>
            <td>
                Emp:
            </td>
            <td>
                <input id="txtEmp" type="text" />
            </td>
        </tr>
        <tr>
            <td>
                User:
            </td>
            <td>
                <input id="txtUser" type="text" />
            </td>
        </tr>
        <tr>
            <td>
                Pass:
            </td>
            <td>
                <input id="txtPass" type="text" />
            </td>
        </tr>
        <tr>
            <td>
                <!--<button id="btnSubmit1" value="button" type="submit"></button>-->
                <input id="btnSubmit1" type="button" value="button" />
            </td>
        </tr>
    </table>
    <div><table id="datagrid"></table></div>
</form>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("[id*=btnSubmit1]").click(function () {
            var emp = $.trim($("[id*=txtEmp]").val());
            var user = $.trim($("[id*=txtUser]").val());
            var pass = $.trim($("[id*=txtPass]").val());
            $.ajax({
                type: "POST",
                url: "Service.asmx/SELECT_ALL_CATEGORIAS",
                data: "{ EMP_ID: " + emp + ", UserName: '" + user + "', Password: '" + pass + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    debugger;
                    if (!data) {
                        alert('Fornecedor não encontrado. Por favor verifique e tente novamente.');
                    } else {
                        var tabela = $("#datagrid");
                        var rows = "";
                        tabela.find("tbody td").remove();
                       // var myData = data.d;
                        var myData = JSON.parse(data.d);
                        for (var i = 0; i < myData.length; i++) {
                            var obj = myData[i];

                            rows += "<tr>";
                            rows += " <td>" + obj.id + "</td>";
                            rows += " <td>" + obj.descricao + "</td>";
                            rows += " <td>" + obj.filial_id + "</td>";
                            rows += " <td> <input type='checkbox' /> </td>";
                            rows += "</tr>";
                        }

                       // tabela.find("tbody").html(rows);
                        tabela.html('<tbody>' + rows + '</tbody>');
                    }
                },
                error: function (data) {
                    debugger;
                    alert('Error');
                }
            });
            return false;
        });
    });
</script>

the layers I want you to consume the webservice are using the Cordova framework.

  • Which error you present???

  • Yeah, I wish I knew the mistake too...

  • only the error message, when debugging the javascript from is as if the webservice did not return anything, I put this layer to download at (https://drive.google.com/open?id=0B9d2JiMn6F9hYXNnYWtUaE9rNWs) in config already configured the test database that is in the kinghost, am using visual studio 2015, framework 4.5.2

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.