Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8922293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:47:47+00:00 2026-06-15T06:47:47+00:00

I am sending a variable to jquery side from my view. And what i

  • 0

I am sending a variable to jquery side from my view. And what i want is taking and using that value in my js file. i tried $.post or response.xx but didn’t work. here is my related view part:

                try:
                    post = Post(title=title, body=body, isdraft=isdraft, owner=owner)
                    post.save()
                except:
                    post = None
                json_dump = simplejson.dumps(post.id)
                return HttpResponse(json_dump, mimetype='application/json')

i can see post.id in firebug’s response part. but how can i use that value in my js file.what i am trying to do is like:

        var auto_save_id = $('#auto_save_id').val();
        if (VALUE_FROM_JSON)){
            auto_save_id = VALUE_FROM_JSON;
        }

thank you

edit : here is my all related view part:

if 'auto_save_id' in request.POST:
        if request.POST['auto_save_id'] == "0":
            title = request.POST['title']
            body = request.POST['body']
            get_isdraft = request.POST['isdraft']
            if get_isdraft == "True":
                isdraft = True
            else:
                isdraft = False
            owner = request.user
            if request.is_ajax():
                try:
                    post = Post(title=title, body=body, isdraft=isdraft, owner=owner)
                    post.save()
                except:
                    post = None
                json_dump = simplejson.dumps(post.id)
            return HttpResponse(json_dump, mimetype='application/json')
        else:

            post_id = request.POST['auto_save_id']
            title = request.POST['title']
            body = request.POST['body']
            get_isdraft = request.POST['isdraft']
            if get_isdraft == "True":
                isdraft = True
            else:
                isdraft = False
            owner = request.user
            post = Post.objects.get(id=eval(post_id))
            if request.is_ajax():
                post.title = title
                post.body = body
                post.isdraft = isdraft
                post.owner = owner
                post.save()
                json_dump = simplejson.dumps(post.id)
            return HttpResponse(json_dump, mimetype='application/json')

i have a hidden input which value is “0”. on first load of page that value is “0” 10 secs later auto_save function runs and send data to view. in view , i check if the auto_save_id = 0: if it is , i create new post and send that post’s id to template side. after that on every 10 secs ajax must UPDATE that post. to prevent create new post on each 10 secs, i need saved post’s id.

i hope this is clear.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:47:48+00:00Added an answer on June 15, 2026 at 6:47 am

    First, I think you want to send a dictionary to simplejson.dumps() like:

    json_dump = simplejson.dumps({'pid': post.id})
    

    Then, in your javascript function, you would get the id with your argument.pid like:

    function myCallback(data){
        alert(data.pid);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I sending ajax request from a jQuery file like below, which expects response in
I have a client-side script written in jQuery that is sending text/xml data to
I'm sending a JSON object to PHP using jQuery via $.ajax({ url: myURL, type:
Is there any way how to call JQuery function from PageLoad C# file? Basically
I've got a Perl script that I want to invoke from a Python script.
Is there a library call that would allow for sending/receiving of variable sized messages
I am new to Javascript and Jquery. I am using Jquery $.ajax for sending
Im having troubles sending a variable from php to javascript. I pull javascript (Ajax)
I am sending the following variable to the jQuery load method, expecting only the
I am sending a json string using JQuery.ajax to a php page where I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.