jquery tools Overlay: Open an overlay on based on ajax response -
I am trying to open an overlay on a button click. The button has an AJAX call attached to it, which should open an overlay if it returns an error, but the overlay will not open on the success.
What happens is that the overlay opens regardless of success / error in AJAX response. This button opens on click, not on Ajax response. What am I missing here ???
What I'm trying here ...
// Overlay Setup $ ('# Post Question'). Overlay ({Target: "#template"}); // Ajax Call Setup $ ('# Post Question'). Click (function () {$ .ajax ({url: '/ ask_away', data type: "jason", data: {question: 'some'}, type: 'post', cache: wrong, success: function Reaction) {Warning ("This was a success");} Error: Work (request, error) {$ ('# Post Question'). Data ('Overlay'). Load ();}});}); & Lt ;! - HTML here - & gt; & Lt; Div id = "template" & gt; You got an error & lt; / Div & gt; & Lt; Div id = "Q & A" & gt; Ask a question & lt; / Div & gt; Overlay Ajax is showing the relation to the success of the call / error because it: < / P>
$ ('#country'). Overlay ({Target: "#template"}); Originally defines the click handler to open an overlay # over by the query questionnaire. So once you click on the postquestion, you not only send Ajax but also show the overlay (which is the result of the code snippet above).
To work as desired, check the code below just one more quick side-note - even if the AJAX call 200 returns 200 OK, but the correct Jason data error handler will not be used , So keep in mind while developing it.
$ (function () {// overlay setup // select the overlay element in the jQuery selector and trigger element $ ("# template") .overlay (); // Ajax call setup $ ('# Q & A'). () {$ .ajax ({url: '/ ask_away', data type: "Jason", data: {question: 'some'}, type: 'post', cache: false , Success: work (response) {alert ("it was a success");}, error: work (request, error) {$ ("# template"). Data ('overlay'). Load ();}} );}}}})
Comments
Post a Comment