Click here to Skip to main content
15,898,571 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Somebody please help me to solve this error...




C#
sb.AppendLine("$().toastmessage('showToast', {");
 sb.AppendLine("    text: '" + Message + "',");
 sb.AppendLine("    sticky: true,");
 sb.AppendLine("    position: 'top-right',");
 sb.AppendLine("    type: 'success',");
 sb.AppendLine("    closeText: '',");
 sb.AppendLine("            }

);");

above code generates this code during runtime

C#
$().toastmessage('showToast', {
    text: 'Message Alert',
    sticky: true,
    position: 'top-right',
    type: 'success',
    closeText: '',
            });



0x800a1391 - Microsoft JScript runtime error: '$' is undefined

and this is my actual jquery file whose function i am trying to call
C#
(function (c) {
    var b = { inEffect: { opacity: "show" }, inEffectDuration: 600, stayTime: 5000, text: "", sticky: false, type: "notice", position: "top-right", closeText: "", close: null };
    var a = { init: function (d) {
        if (d) {
            c.extend(b, d)
        }
    }, showToast: function (f) {
        var g = {};
        c.extend(g, b, f);
        var j, e, d, i, h;
        j = (!c(".toast-container").length) ? c("<div></div>").addClass("toast-container").addClass("toast-position-" + g.position).appendTo("body") : c(".toast-container");
        e = c("<div></div>").addClass("toast-item-wrapper");
        d = c("<div></div>").hide().addClass("toast-item toast-type-" + g.type).appendTo(j).html(c("<p>").append(g.text)).animate(g.inEffect, g.inEffectDuration).wrap(e);
        i = c("<div></div>").addClass("toast-item-close").prependTo(d).html(g.closeText).click(function () {
            c().toastmessage("removeToast", d, g)
        });
        h = c("<div></div>").addClass("toast-item-image").addClass("toast-item-image-" + g.type).prependTo(d);
        if (navigator.userAgent.match(/MSIE 6/i)) {
            j.css({ top: document.documentElement.scrollTop })
        } if (!g.sticky) {
            setTimeout(function () {
                c().toastmessage("removeToast", d, g)
            }, g.stayTime)
        } return d
    }, showNoticeToast: function (e) {
        var d = { text: e, type: "notice" };
        return c().toastmessage("showToast", d)
    }, showSuccessToast: function (e) {
        var d = { text: e, type: "success" };
        return c().toastmessage("showToast", d)
    }, showErrorToast: function (e) {
        var d = { text: e, type: "error" };
        return c().toastmessage("showToast", d)
    }, showWarningToast: function (e) {
        var d = { text: e, type: "warning" };
        return c().toastmessage("showToast", d)
    }, removeToast: function (e, d) {
        e.animate({ opacity: "0" }, 600, function () {
            e.parent().animate({ height: "0px" }, 300, function () {
                e.parent().remove()
            })
        });
        if (d && d.close !== null) {
            d.close()
        }
    }
    };
    c.fn.toastmessage = function (d) {
        if (a[d]) {
            return a[d].apply(this, Array.prototype.slice.call(arguments, 1))
        } else {
            if (typeof d === "object" || !d) {
                return a.init.apply(this, arguments)
            } else {
                c.error("Method " + d + " does not exist on jQuery.toastmessage")
            }
        }
    }
})(jQuery);
Posted
Updated 12-May-13 7:31am
v4

As '$' is actually defined in jQuery, it's likely that you did not include jQuery at all. This is of course my guesswork, as you did not show your HTML <head>. Please see: http://jquery.com/download/[^].

—SA
 
Share this answer
 
I don't know why it is closed, but seriously i got that error because of not adding jquery library in my page.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900