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 8733557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:40:18+00:00 2026-06-13T09:40:18+00:00

Im having some troubles getting this ajax call to work. The ajax function pass

  • 0

Im having some troubles getting this ajax call to work. The ajax function pass a simple variable to my python controller and the controller returns the result of a query. Im working with Web2py framework. The error im getting: cannot concatenate ‘str’ and ‘NoneType’ objects. And this is the code:

Ajax Call:

<script>
function TestVolumen() {
    var selectVal = $('#zonas :selected').val();    
    $.ajax({
    data: selectVal ,
    url: '/shell/default/ajax2',
    type: 'POST',
    cache: false,
    dataType: 'string',
    success: function(request) {
    //console.log(request[0]);
    //console.log(request[0].zona);
    selectVal = $('#zonas :selected').val();

        for (x=0;x<request.length;x++){
            if (request[x].zona == selectVal ) {
            //alert(request[x].promedio);
            //alert(request[x].zona);
            $('div#tabs .vol').html(request[x].promedio.toFixed(4));

            }
        }

        }
    });
}
</script>

And this is the python controller:

def ajax2():
import gluon.contrib.simplejson
zona = request.vars

queryvol = "select sells.product1 FROM site inner join zona on site.zone_number = zona.id inner join sells on sells.site = site.id WHERE zona.id =" + zona +" ;', as_dict = True"
vol=db.executesql(queryvol)

return gluon.contrib.simplejson.dumps(vol)

Thanks for the help!! I really appreciate it.

  • 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-13T09:40:19+00:00Added an answer on June 13, 2026 at 9:40 am

    The Python error you see means that the value of zona is simply None. I guess this is due to a fact that you make the AJAX request incorrectly. When making a request you should define the data in { 'variable_name' : value } format. For server-side: note that request.vars is gluon.storage.Storage dictionary-like object.

    So, to fix this – modify your AJAX request by removing dataType: 'string', and setting data to something like { 'zona' : selectedVal }. Second – use request.vars['zona'] to get the value on the server-side. Third – before writing Python code any further, read an memorize PEP8 by heart!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having troubles getting this to work. Basically I have a python program that
So i've been having some troubles getting this effect to work. Here is an
I'm having some trouble getting this to work using one function, instead of having
Ok this seems so silly but I'm having some trouble getting this to work.
I am having some troubles getting some regex to work to remove some text,
I'm having some troubles getting a set of Entities setup to work correctly. I'm
I'm having some troubles debugging this and getting a resolution. My data is being
Having some trouble getting this to work... I basically want the report to look
I'm having some trouble getting this to work in a WPF app I'm working
I'm having some troubles getting gettext work on a Linux server. It works on

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.