Your Javascript syntax is incorrect -- the text inside .html() must be
wrapped in quotes:
"jQuery('#status').html('%s');" % (str(status))
Anthony
On Friday, May 15, 2015 at 9:13:21 PM UTC-4, 黄祥 wrote:
>
> hi,
>
> is it possible to have ajax callback return string type data?
> e.g.
> controllers
> def callback_2(session_order, target_response):
> ... cutted
> if int(total_debit) == int(total_credit):
> #status = "Balance"
> #status = str("Balance")
> status = 1
> else:
> #status = "Unbalance"
> #status = str("Unbalance")
> status = 0
> #return "jQuery('#status').html(%s);" % (status)
> return "jQuery('#status').html(%s);" % (str(status) )
>
> all comment is not worked (no errors occured, but the result is not
> shown), when change it into integer type it can work (shown in views). any
> idea how to achieve it using web2py way?
>
> i know i can put another conditional in views for that, but i want to know
> another way to achieve this
> e.g.
> views
> {{if status == 1:}}
> <td>{{=SPAN('Balance', _class = "text-success" ) }}
> </td>
> {{else:}}
> <td>{{=SPAN('Unbalance', _class = "text-danger" ) }}
> </td>
> {{pass}}
>
> thanks and best regards,
> stifan
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.