Reputation: 2175
I have a web2py application and am using jQuery to validate data. I want to write Python code inside jQuery. How can I do that?
if($("#myform_parent_id")[0].value != ''
&& $("#myform_parent_birthdate")[0].value != ''
&&
// Here I want to write Python code
..
}
Because when i make this code inside controller and then return the form it is reset selected values.
Upvotes: 0
Views: 1955
Reputation: 11
Silverlight allows you to embed Python as a scripting language on the client-side. http://www.voidspace.org.uk/ironpython/silverlight/index.shtml
Upvotes: 1
Reputation: 29452
If you define this code in the view (instead of the controller) then you can use Python code within {{ }} blocks.
Upvotes: 1
Reputation: 23559
As no browser will understand Python, you'll have to make an Ajax call to the server if you really want to use Python. This will probably complicate things for you, if only as Ajax calls are asynchronous by definition. But jQuery does support it.
Alternatively, to keep it all within the browser, you need JavaScript-only. If you can't translate your Python to JavaScript yourself, you could take a look at automated conversions.
Upvotes: 0