javascript - 将变量传递给 window.location.replace 以进行重定向
问题描述
我试图在函数成功后将我的页面重定向到另一个页面,但它没有读取我在 window.location.replace 中的变量。
var thenum = client.replace( /^\D+/g, '');
$.ajax({
url: '/signature_pad.php',
type: 'POST',
data: {
imageData: imagen,
id: thenum,
},
})
.done(function (msg) {
// Image saved successfuly.
window.location.replace('http://something.com/show.php?id=${ thenum }');
})
.fail(function (msg) {
console.log("error: " + msg);
});
有什么方法可以将我重定向到http://something.com/show.php?id=${ num } 它必须将变量传递给 id
解决方案
需要改变
window.location.replace('http://something.com/show.php?id=${ thenum }');
至
window.location.href = ('http://something.com/show.php?id=' + thenum);
推荐阅读
- python - 在 python 中为特定的 json 元素轮询 api
- python - 不同包中的 SQLAlchemy InvalidRequestError
- python - 在 Bokeh 1.4.0 中使用 box_select 工具“隐藏”而不是“静音”字形
- reactjs - Firebase Firestore 如何从函数返回 onSnapshot 数据值
- python - Pyspark 创建名称中包含非字母数字字符的行
- database - 我正在设计一个多项选择问卷,其选项会根据您所做的选择而变化。这样的事情存在吗?
- firebase - 重定向/无法为 Firebase 上托管的 Vue 应用程序中的服务人员获取错误
- algorithm - 手动比较对象的有效方法?
- python - 关于生成特定长度数组的问题
- javascript - 在 vuejs 中使用条件内部过滤器()?