Привет всем, пытаюсь подключить плагин noty2 для jQuery в свой проект, но возникли трудности:
- Подключаю плагин точно так, как написано здесь
Делаю яакс запрос и в случае его состояния complete или success вызываю noty:
$(document).ready(function(){ $('#login').submit(function(e){ e.preventDefault(); var formData = $("#login").serialize(); alert(formData); $.ajax({ url: $(this).attr("action"), type: "POST", data: formData, success: function (msg) { if (msg.length > 0) { //alert(msg); alert("Вы успешно авторизированны!!!"); noty({text: 'noty - a jquery notification library!'}); } else { $(location).attr('href', updView + "/" + id); } }, error: function (jqXhr, textStatus, errorThrown) { alert("Error '" + jqXhr.status + "' (textStatus: '" + textStatus + "', errorThrown: '" + errorThrown + "')"); }, complete: function () { window.location.href = "../index.php"; } }); return false; });
});
Почему аякс запрос срабатывает, алерты срабатывают, а вызов noty нет?
Статья на Хабре про Ноти - http://habrahabr.ru/post/149665/
Похожая тема на СО - https://stackoverflow.com/questions/13712587/jquery-notification-bar
Ошибка в Хроме:
Uncaught TypeError: Cannot read property 'options' of undefined
NotyObject.init jquery.noty.js:37
$.notyRenderer.init jquery.noty.js:268
noty jquery.noty.js:546
$.ajax.success login.php:299
l jquery-2.0.2.min.js:4
c.fireWith jquery-2.0.2.min.js:4
k jquery-2.0.2.min.js:6
(anonymous function) jquery-2.0.2.min.js:6
Ошибка в Файрфоксе:
--
[22:35:38.489] TypeError: this.options.layout is undefined @ http://im.loc/js/noty/jquery.noty.js:37
Ошибка в Опере:
Uncaught exception: TypeError: Cannot convert 'this.options.layout' to object
Error thrown at line 37, column 12 in <anonymous function: init>(options) in http://im.loc/js/noty/jquery.noty.js:
this.options = $.extend({}, this.options, this.options.layout.options);
called from line 268, column 8 in <anonymous function: $.notyRenderer.init>(options) in http://im.loc/js/noty/jquery.noty.js:
var notification = Object.create(NotyObject).init(options);
called from line 546, column 4 in noty(options) in http://im.loc/js/noty/jquery.noty.js:
return jQuery.notyRenderer.init(options);
called from line 299, column 24 in <anonymous function: success>(msg) in http://im.loc/login.php:
noty({text: 'noty - a jquery notification library!'});
called via Function.prototype.apply() from line 4, column 49671 in <anonymous function: x.Callbacks>(p) in http://im.loc/js/jquery-2.0.2.min.js:
if(a[s].apply(p[0],p[1])===!1&&e.stopOnFalse)
called from line 4, column 51258 in <anonymous function: fireWith>(e, t) in http://im.loc/js/jquery-2.0.2.min.js:
return t=t||[],t=[e,t.slice?t.slice():t],!a||n&&!u||(r?u.push(t):l(t)),this
called from line 6, column 8930 in k(e, t, o, a) in http://im.loc/js/jquery-2.0.2.min.js:
2!==v&&(v=2,s&&clearTimeout(s),n=undefined,i=a||"",T.readyState=e>0?4:0,l=e>=200&&300>e||304===e,o&&(b=pn(c,T,o)),b=fn(c,b,T,l),l?(c.ifModified&&(w=T.getResponseHeader("Last-Modified"),w&&(x.lastModified[r]=w),w=T.getResponseHeader("etag"),w&&(x.etag[r]=w)),204===e||"HEAD"===c.type?C="nocontent":304===e?C="notmodified":(C=b.state,m=b.data,y=b.error,l=!y)):(y=C,(e||!C)&&(C="error",0>e&&(e=0))),T.status=e,T.statusText=(t||C)+"",l?h.resolveWith(p,[m,C,T]):h.rejectWith(p,[T,C,y]),T.statusCode(g),g=undefined,u&&f.trigger(l?"ajaxSuccess":"ajaxError",[T,c,l?m:y]),d.fireWith(p,[T,C]),u&&(f.trigger("ajaxComplete",[T,c]),--x.active||x.event.trigger("ajaxStop")))
called from line 6, column 17219 in <anonymous function: t>() in http://im.loc/js/jquery-2.0.2.min.js:
t&&(delete vn[o],t=s.onload=s.onerror=,"abort"===e?s.abort():"error"===e?r(s.status||404,s.statusText):r(mn[s.status]||s.status,s.statusText,"string"==typeof s.responseText?{text:s.responseText}:undefined,s.getAllResponseHeaders()))