jquery - How to clear the value of a javascript variable? -


I am using a javascript wizard to control the running of an AJAX call. Call starts with one click event (on "#week _tag " div) and only needs to be run once per page load. The same click event also has a sliding panel ("#week_summary") Toggles the display where data from the AJAX call is shown.

In the example below, I am trying to use a variable and a statement, when the Ajax call is called the "#week _tag " sliding panel by the user name Second time to close The vera status is set to "first" when "page" is loaded, and AJAX is set to "after" after the call. If the WAR state status is equal to "before", then the call is in progress, otherwise the "#week_summary" bus has been toggled. This is not working because I do not know how to give "status" to the second value of "latter". Any ideas?

  $ (document) .ready (function () {var status = "before"; alert ("before:" + status); $ ('# week_tag'). (Function () {If (status == "before") {alert ("afterclick:" + status); var form_date_set = $ ("input [name = 'date_set']"). Val (); $ .post "/ tortus / index $. ('#week_summary' Toggle ('Blind'); Warning ("After:" + Status);});});  

That's because you are declaring a new variable inside the callback function, Local area it If you remove var from the callback function, then it should work as expected.

  $ .post ("/ tortus / index.php / daylog / build_summary", {date_set: form_date_set}, function (html) {$ ("# week_summary"). Html (html) ; Condition = "post"; warning ("status:" + status);});  Edit:  And of course, as mentioned in the comment below, because the call has been called Asynch, you also have to alert the situation on the callback. Or create a new onclick event on some random element, which will only display the status:  
  $ (document) .ready ({var status = "before" ... // your previous onclick event Here ... $ ("#new elm"). Click (function () {warning ("status:" + status);});});  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -