Question

I keep getting a "error:undefined" message when calling this AJAX method.

$.ajax({
            type: "GET",
            async: false,
            url: "localhost/ServiceHost/Security.svc/GetAllUserErrors",
            data: "{ }",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            dataFilter: function (data) { return data; },
            success: function (data) {
                for (var i = 0; i < data.d.length; i++) {
                    if (i % 2 == 0) rows += "<tr><td><input  type=\"checkbox\"/></td>";
                    else rows += "<tr class=\"alternate-row\"><td><input  type=\"checkbox\"/></td>";
                    rows += "<td>" + data.d.SyncTimeStamp.toString() + "</td>";
                    rows += "<td>" + data.d.Name.toString() + "</td>";
                    rows += "<td>" + data.d.Login.toString() + "</td>";
                    rows += "<td>" + data.d.NotificationText.toString() + "</td>";
                    rows += "<td class=\"options-width\"><a href=\"\" title=\"Edit\" class=\"icon-2 info-tooltip\"></a></td></tr>";
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus + ":" + errorThrown);
            }
        });

I know that the WCF is running but I can't figure out why I'm getting this error. Any help?

I'm sure that the problem is somewhere in the 'url' part. What is the proper syntax for this line?

    <services>
      <service name="Security.WCFServiceLibrary.Security">
        <endpoint address="" binding="wsDualHttpBinding" bindingConfiguration=""
          contract="Security.WCFServiceLibrary.ISecurity" />
      </service>
    </services>
Was it helpful?

Solution

Apart from your SJAJ architecture (...)?

I'd say that your "localhost" is not a folder next to your html page, but an absolute path maybe? http://localhost/

then, when data will be defined, you will also need to parse it into a proper Javascript Object, as your JSON is only a "notation".

var jsonData = jQuery.parseJSON(data);

Then you can use jsonData as a real js object. Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top