0

I am calling a .NET code from my jquery. The process is being performed fine but anyway I am getting an error.

UPDATE:

The issue comes up when using an ASP Button

     <asp:Button ID="Button1" runat="server" ValidationGroup="gr1" Text="Enviar" OnClientClick="if(Page_ClientValidate()) send();" UseSubmitBehavior="false" CssClass="sbutn" />
       

Not with a plain html button

<button type="button" onclick="send()">Send me the list</button>

Here is the code

var send = function () {
    var array = localStorage.getItem("array");
        $.ajax({
        type: "POST",
        url: "Propiedades_Favoritas.aspx/SendData",
        data: JSON.stringify({
            "data": {
                "array": array,
                "email": $('#txtEmail').val(),
                "name": $('#txtNombre').val()
            }
        }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            localStorage.removeItem("array");
            localStorage.removeItem("data");
            location.href = "Propiedades_Favoritas_Enviados.aspx?Fname=" + msg.d;
        },
        error: function (jqXHR, textStatus, errorThrown) {
            console.log(jqXHR);
            console.log(textStatus);
            console.log(errorThrown);
        }
    });
}

The .NET part looks like this

 <WebMethod(EnableSession:=True)>
<ScriptMethod()>
Public Shared Function SendData(ByVal data As Dictionary(Of String, Object)) As String

    Dim v1 As Object
    Dim v2 As Object
    Dim v3 As Object
    data.TryGetValue("array", v1)
    data.TryGetValue("email", v2)
    data.TryGetValue("name", v3)
    v1 = v1.Substring(1, v1.Length - 2)

    Dim sArchivo As String

    Dim dtDate As Date = System.DateTime.Now
    sArchivo = "Propiedades_"
    sArchivo &= dtDate.DayOfYear.ToString.PadLeft(3, "0")
    sArchivo &= dtDate.Hour.ToString.PadLeft(2, "0")
    sArchivo &= dtDate.Minute.ToString.PadLeft(2, "0")
    sArchivo &= dtDate.Second.ToString.PadLeft(2, "0")
    sArchivo &= dtDate.Millisecond.ToString.PadLeft(3, "0")

    ...... all this code is working fine
    '

    Return sArchivo & ".pdf"
End Function

But the error is coming up with "error" as textstatus, "empty string" as the errorThrown. I don't know how to understand the jqXHR, it looks like this

The j

Corobori
  • 171
  • 1
  • 10

0 Answers0