首页 > 解决方案 > Ajax Call with URL

问题描述

Hi I would like to build an ajax call with the following app.get function, It is currently not working as the id does not sit in between the /movie/:id(The movieid)/reviews, How can I build an ajax call based on the app.get url requirement ? Thank You!

 app.get('/movie/:id/reviews', function(req,res){
        var movieid = req.params.id;

my current idea for the ajax call is not working

$(document).ready(function () {
            var queryString = window.location.search;
            console.log(queryString);
            var urlParams = new URLSearchParams(queryString);
            if (urlParams.has("movieid")) {

              var movieid = urlParams.get("movieid");
              console.log(movieid);

              $.ajax({
              url: 'http://localhost:8081/movie/'+ movieid +'reviews/' ,
              type: 'GET',
              // data: data,
              contentType: "application/json",
              dataType: "json",

标签: ajaxurl

解决方案


推荐阅读