ajax - 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",
解决方案
推荐阅读
- ruby-install - 如何使用 ruby-install 安装 Ruby 的预览版
- node.js - 如何将返回promise的异步函数转换为节点js中的同步函数
- amazon-web-services - 启用 boto3 在 ECS 实例上发送 SES 而不使用 IAM 访问密钥/秘密
- java - 复制列表
- > 有尺寸限制
- sql - 经常性事件出勤数据库设计
- javascript - 未捕获的错误、语法错误、无法识别的表达式 [JQUERY]
- debugging - clion 调试器“无法找到和加载段”
- video-streaming - GStreamer - RTSP 流到 FLV 文件
- sql-server - SQL Server:将 IPv6 转换为 INTEGER
- sql - 用于将数据库导出到 .bacpac 文件的 Azure ARM 模板