How to define and use ajax URL
I am trying to create conditional URL for Ajax data pull, but it does not work. Any ideas why that is happening? My code looks like below.
- $("#valink").click(function () {
- $("#valink").removeClass("active");
- var key = $(this).text();
- $(this).addClass("active");
- var currRoute = "../content-url/url.php";
- if(key === "Books") {
- currRoute = "../content-url/url1.php";
- } else {
- currRoute = "../content-url/url2.php";
- }
- $.ajax({
- type: "GET",
- url: currRoute,
- async: false,
- dataType: "html",
- data: ({
- key: key, }),
-
- success : function(text){
- $("#link .section").html(text);
- }
- });
-
- });