Search code examples
pythonformscherrypy

Cherrypy splitting form argument when it contains "&"


I am submitting the following form to a python Cherrypy script, this is however splitting the "&" from the form argument, which I do not wish to happen,and would instead want the following output.

Desired output:

{'mate': u'(NSW) Ryde - Upgrade of Power Supplies to New Chillers on Roof Design Construction P2 (RYDZ) (IMC152) (44159)'}

form post link:

"GET /project_details?mate=(NSW)%20Ryde%20-%20Upgrade%20of%20Power%20Supplies%20to%20New%20Chillers%20on%20Roof%20Design%20&%20Construction%20P2%20(RYDZ)%20(IMC152)%20(44159) HTTP/1.1"

here is a print out of the argument that Cherrypy is seeing using the code below,

{' Construction P2 (RYDZ) (IMC152) (44159)': u'', 'mate': u'(NSW) Ryde - Upgrade of Power Supplies to New Chillers on Roof Design '}

Python code:

@cherrypy.expose
    def project_details(self, **mate):
        print mate

Html code:

$.ajax({url: 'http://192.168.0.37:8000/project_details?mate='+selectvalue,
                                     success: function(output) {
                                         alert(output);},

Solution

  • I have solved this thanks to Ignacio, ajax code below;

    $.post( "http://192.168.0.37:8000/project_details", { mate: selectvalue})
                                      .done(function( data ) {
                                        alert( "Data Loaded: " + data );
                                      });