jQuery $.get problem -


I am slightly stumped with the following problem and I'm afraid the solution is very clear but I do not think it is no more problem , How this jQuery code works:

  $ (document) .ready (function () {var q = $ (".box"). Val (); $ .get (" Type: "search", time: "2pm"}, function (twitter) {var tweets = JSON.parse (twitter);});   

But if I make it a part of a click event it will not work:

  $ (d) Ocument) .ready (function () {$ (".btn") .click (function () {var q = $ (". Box"). Val (); $ .get ("db.php", {searchterm : "Test", type: "search", time: "2pm"}, function (twitter) {var tweets = JSON.parse (twitter);})}};  

Of course, the name of a class named 'btn' in my html page

FireBug, an error message in jQuery shines, but so far the console resets, so I read or copy the error from the log Can not do any suggestions?

Maybe you just return false; with click handler?

  $ (document) .ready (function () {$ (".btn"). Click (function () {var Q = $ (". Box"). Val () ; $ .get ("db.php", {searchterm: "test", type: "search", time: "2pm"}, function (twitter) {var tweets = JSON.parse (twitter);}); return false; }); });  

This will stop the default action for the link - that means navigating to the URL.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -