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

  • SEARCH
  • Home
  • 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 6171977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:18:51+00:00 2026-05-23T23:18:51+00:00

How do pass back values to a form that was posted to the server

  • 0

How do pass back values to a form that was posted to the server using Ajax?

In the view (shown below), I am just returning a simple data structure to test things:

def detail(request, widget_id):

    widget = get_object_or_404(Widget, pk=widget_id)

    if request.method == 'POST':
        form = WidgetDetailsForm(request.POST, instance=widget)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(request.path)  # Redirect after POST
        else:
            if request.is_ajax():
                response_dict = {
                    'page': 1,
                    'total': 2,
                    'rows': 3
                }
                json = simplejson.dumps(response_dict)
                return HttpResponse( json, mimetype='application/json')

    else:
        form = WidgetDetailsForm(instance=widget)

    params = {}
    params['widget'] = widget
    params['form'] = form
    return render_to_response('widgets/detail.html', params,
                              context_instance=RequestContext(request))

The JavaScript in the template is:

<script type="text/javascript">
    /* <![CDATA[ */
        // Wait for the DOM to be loaded
        $(document).ready(function() {
            // Bind 'myForm' and provide a simple callback function.
            $('#updateform').wl_Form({
                onSuccess: function(data, status){
                    alert(data);
                    alert(data.page);
                    alert(data.rows);
                    alert(data.total);
                },
                "status": false,
                "confirmSend": false
            });
        });
    /* ]]> */
</script>

I get the following from the alert statements.

{"rows": 3, "total": 2, "page": 1}
undefined
undefined
undefined

Why does data.page, data.rows, and data.total return undefined?

  • 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-05-23T23:18:52+00:00Added an answer on May 23, 2026 at 11:18 pm

    Because data is a string (of JSON) – note the output of your first alert().

    Try something like:

    $('#updateform').wl_Form({ 
        onSuccess: function(response, status){
            var data = $.parseJSON(response); 
            alert(data);
            alert(data.page);
            //...
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how can i pass values from my custom components back to the main.mxml? i
Can an Ajax-enabled WCF Service pass back a DataTable as a Sys.Data.DataTable? Like this
Which method would you recommend to pass data from a child view back to
How do you pass $_POST values to a page using cURL ?
I have form submission doing a post back. The controller action accepts the values
Is there a way to pass a call back function in a Java method?
I would like to pass an argument(s) to a method being defined using define_method,
I have a form that jQuery tracks the onChage .change() event so when something
I've got a situation where I have a main form that pops up an
hi im trying to pass some values to a class but it wont let

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.