Comments (3)
from djangopracticeproject.
你看 我想通过视图函数返回当前文章的id与slug给对应页面的javascript代码
<script type="text/javascript">
function publish_article(){
var title=$("#id_title").val();
var column_id=$("#which_column").val();
var body=$("#id_body").val();
$.ajax({
url:"{% url 'article:article_post' %}",
type:"POST",
data:{"title":title,"column_id":column_id,"body":body},
success:function (e) {
e=JSON.parse(e);
id=e["id"];
slug=e["slug"];
if(e["e"]=="1"){
layer.msg("successful.");
location.href="{% url 'article:article_detail' id slug %}";
}else if(e["e"]=="2"){
layer.msg("sorry.");
}else{
layer.msg("项目名称必须写,不能空");
}
},
});
}
</script>
但是这里javascript里面无法给{% url %}取到id 跟 slug的值
该怎么做?
from djangopracticeproject.
from djangopracticeproject.
Related Issues (14)
- www.itdiffer.com无法访问 HOT 1
- 源码2.0还有bug
- 内置方法重置密码
- 源码2.0中的Except语句缺少错误类型 HOT 1
- Django 实战 (2017, 第一版) 217页中的数据迁移问题 HOT 2
- 裁剪图片的ajax不能提交 HOT 3
- 裁剪图片为什么只是显示一小部分 HOT 2
- Dango实战一书中一个小问题 HOT 1
- Class 'BlogArticles' has no 'objects' member HOT 3
- djang2.0内置登录方法等,已经不用login,loginout HOT 1
- 求更新django2.0中的代码 HOT 1
- 展示个人信息章节,用get()会报错 HOT 1
- 求指点 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from djangopracticeproject.