javascript - How to declare Popup message in the site.Master page for My Entire Application using Jquery? -


i need show same popup message throwout entire application showing success message failure message? please wait message? entire application..

in application if click save if taking time need show please wait pop message while loading page..

can body me out how declare in site.master page this? using jquery

thanks

you want define functions in master page , call them appropriate.

lets add div master page.

     <div id="messagedisplay">      </div> 

you of course want style message css , position div want it.

// display success message. function successmessage() {      $('#messagedisplay').text('your operation successful!').slidedown(); } 

or define function can pass in message want display.

// display message. function displaymessage(messagetext) {      $('#messagedisplay').text(messagetext).slidedown(); } 

i prefer second method define 1 function , pass string whenever call it.

to hide message define hide function.

// hide displayed message. function hidemessage() {      $('#messagedisplay').slideup(); } 

then in pages call functions. pretend have ajax operation going take long time. first display "please wait..." , "successful!" when done.

$('#somebutton').click(function () {      hidemessage();      displaymessage("please wait...");      $.ajax(      {           url: "some/url/for/ajax/function",           data: { somedata: "some data" },           type: "post",           success: function (response)           {                hidemessage();                displaymessage("successful!");           },           error: function (xhr, textstatus, errorthrown)           {                hidemessage();                displaymessage(textstatus);           }      }); }); 

edit: remember when page inherits master page, browser sees 1 page altogether. javascript defined on master page included part of every page point forward, means page-specific scripts reference functions defined in master page fine.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -