var mypersistdict = {};
mypersistdict['myvar'] = 'myvalue';
var myurlencodeddata = $.param(mypersistdict);
// ref:
http://stackoverflow.com/questions/19254029/angularjs-http-post-does-not-send-data
$http({
method: 'POST',
url: ''http://myweb2pyuri',
data: myurlencodeddata ,
headers: { 'Content-Type':
'application/x-www-form-urlencoded' } // GOTCHA: web2py methods NOT marked
restful expect urlencoded vars, NOT JSON which Angular usually sends, so
override with headers here...
}).
success(function (data1, status, headers, config)
{
// this callback will be called asynchronously
// when the response is available
debugger;
}).
error(function (data1, status, headers, config)
{
// called asynchronously if an error occurs
// or server returns response with an error status.
debugger;
});
I have not tried marking my web2py method as restful yet. I am guessing
that the restful method will then expect the JSON encoding and then the
header override here will not be needed.
On Tuesday, September 16, 2014 1:39:02 PM UTC-5, piero crisci wrote:
>
> I am testing angularjs with web2py.
> In my web2py i have some ajax call that store the html code into a dialog
> box.
> Now i would like to insert in html code from the callback some angularjs
> code.
> But because ajax call is not into angular module , the code is not running.
> The angular MVC work instead properly into main pages.
> Anyone is trying the same thing or got some hints for me?.
> I cannot find any examples of how use web2py ajax (or jquer ajax) with
> angularjs
>
--
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.