Giter Club home page Giter Club logo

Comments (3)

qiwsir avatar qiwsir commented on July 19, 2024

from djangopracticeproject.

Myfour avatar Myfour commented on July 19, 2024

你看 我想通过视图函数返回当前文章的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.

qiwsir avatar qiwsir commented on July 19, 2024

from djangopracticeproject.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.