1

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>
2
  • 2
    async: false - Does anyone know a good exorcist? :D
    – Andreas
    Aug 13, 2012 at 18:35
  • Please post the relevant sections of your web.config.
    – schglurps
    Aug 13, 2012 at 18:38

1 Answer 1

1

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.