Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
28494 มุมมอง

favorite   
I have a strange problem here,i need to call a function from controller using route,i try to catch the request and call the function but still have problems
here is my jquery code:

this.couponcode= jQuery('#apply-button');
    this.couponcode.on('click', function () {    var code = jQuery('#promotional').val();
    jQuery.ajax({type: "GET",        url:'add_numbers',        data: {'code': code, 'task': 'addcode', 'format': 'json'},        dataType: 'json',        success: function (response)        {          console.log(response)        }    });
});


and here is my python function

 

@http.route('/page/add_numbers', auth='public', type='http',website=True)    def trial_check(self, **post):
        print 'Callllllllllllllllllllllllled'        return request.render('website.register')


อวตาร
ละทิ้ง
ผู้เขียน

I have a strange problem here,i need to call a function from controller using route,i try to catch the request and call the function but have problems in print function ... but when i use "logging" it run perfectly

here is my jquery code:

this.ncode= jQuery('#apply-button');

this.ncode.on('click', function () {

var scode = jQuery('#prqcd').val();

jQuery.ajax({type: "GET",

url:'/page/add_numbers',

data: {'scode ': scode , 'task': 'addcode', 'format': 'json'},

dataType: 'json',

success: function (response)

{

console.log(response)

}

});

});

and here is my python function

@http.route('/page/add_numbers', type='http', auth="public", methods=['GET'], website=True)

def tag_read(self, **post):

print 'Calllled', post

return request.render('website.pricing')

คำตอบที่ดีที่สุด

If your have multiple langs installed and active for the website, what could be breaking your ajax request is the website=True argument that cause a redirect to the same URL rewrited with the lang attached to the URL and causing the error to the ajax request.

@http.route('/page/add_numbers', auth='public', type='http')
def trial_check(self, **post):
    print 'Callllllllllllllllllllllllled'
    return request.render('website.register')
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ม.ค. 24
3677
Controller not working แก้ไขแล้ว
2
ก.พ. 23
2425
1
มี.ค. 21
18175
How to get model object from Controller แก้ไขแล้ว
3
ก.ค. 20
12178
0
เม.ย. 20
3734