Javascript ajax call post incomplete data

831 views Asked by At

I had an unusual situation occuring in production while doing a asynchronous ajax post.

<script type="text/javascript">
    Mylib.defined('jQuery', function() {
        jQuery.ajax({
            'type':    'POST',
            'url':   '/my/url.html',
            'async':   true,
            'cache':   false,
            'global':  false,
            'data':    {
                    'param1': 'value1' ,
                    'param2': 'value2'
            }
      });
  });

Mylib.defined(functionality,callback()) wait for the functionality to load and then triggers the callback function.

/my/url.m is mason file and takes two parameters out of which 'param1' has been made essential, that it should be present in posted data.

Contents of /my/url.m

<%args>
    param1
    param2 => undef
</%args>
<%perl>
   -----
 </%perl>
<%args>

Problem

I was having a sense that since we are posting JSON data from our ajax call(see JS above), whose key param1 is hard coded(Though value1 is dynamic), I will never get into a situation where endpoint(mason file) won't be passed the param1 which is essential. But to my surprise there were hell lot of cases where param1 was not passed to mason file. I was not able to get this.Can someone help me here?

Can web-crawlers hit the url /my/url.html without any arguments?

0

There are 0 answers