How to pass JavaScript Variables with AJAX calls?

JavascriptWeb DevelopmentFront End Technology

To pass JavaScript variables with AJAX calls, replace the following −

var page = parseInt(getUrlParameter('page'));

With −

var page = +getUrlParameter("page") || 100;

Example

Try the following code to correctly pass variables with AJAX calls −

Live Demo

<html>
   <script>
      function getUrlParameter ( param ) {
         return param === "page" ? 500 : false;
      }
      var page = +getUrlParameter("Demo") || 100;
      alert(page);
      page = +getUrlParameter("page") || 100;
      alert(page);
   </script>
   <body>
   </body>
</html>
raja
Published on 18-Jan-2018 13:06:14
Advertisements