ravi
unread,Jul 6, 2012, 6:33:48 AM7/6/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-discuss
Hi,
I need help in the following issue.
JavaScript AJAX Call:
*****************************************************************
$.ajax({
type: "POST",
url: mw.config.apiBase +
"export_csv",
contentType: "application/json;
charset=utf-8",
data: {'obj':'test data'},<This can
be huge json data i want to pass>
dataType: "json",
success: function(response) {
alert(response)
}
});
******************************************************************
Python code snippet:
********************************************************************
# General Imports
import csv, sys, os, tempfile
from pylons import request, response, session, tmpl_context as c
from pylons.controllers.util import abort, redirect
from mapfish.protocol import create_default_filter
from mapfish.decorators import MapFishEncoder, geojsonify, _jsonify
# Local imports
from myworldapp.lib.simple_controller import SimpleController
from myworldapp.model.meta import Session
from myworldapp.lib.myw_authorizer import MywAuthorizer
class ExportCsvController( SimpleController ):
readonly = False # if set to True, only GET is supported
def __init__(self):
SimpleController.__init__( self )
#
# Build an authorizer to authorize transactions.
#
self.authorizer = MywAuthorizer( session, False )
@geojsonify
def index( self):
#
# GET /: return all features.
#
if not self.authorizer.isRequestAuthorized( request ):
abort( 403)
<How to read data sent from the AJAX>
********************************************************************
Now I want read the sent data(data: {'obj':'test data'}) from AJAX in
index method of python code
Please help me in resolving the issue
Thanks in advance