Unfortunately, this is not the case with a legacy system I have used. Therefore, the call method is transformed by applying the ajaxPrefilter of jQuery on the client.
Copy codeThe Code is as follows: <Head>
<Title> ajaxPrefilter demo </title>
</Head>
<Body>
<Script type = "text/javascript" src = "http://code.jquery.com/jquery-latest.min.js"> </script>
<Script type = "text/javascript">
Var zoneAjaxUrl = '/ajax. php ';
Var zoneAjaxRoute = // ajax \/(\ w + )(\?. *)? /;
$. AjaxPrefilter (function (options, originalOptions, jqXHR ){
// Console. log (options. url, '\ n', originalOptions. url );
Var m = options. url. match (zoneAjaxRoute)
If (m ){
Var routed = {
Dir: m [1], page: m [2], action: m [3],
Args: JSON. stringify (originalOptions. data)
}
Options. url = zoneAjaxUrl + (m [4] | '');
Options. data = $. param (routed );
}
});
Var url = '/ajax/dir/page/action ';
// Var url = '/ajax/dir/page/action? A = 1 & B = 2 ';
Var url_jsonp = '/ajax/dir/page/action? Callback =? ';
// Var url_jsonp = '/ajax/dir/page/action? A1 = 2 & b1 = 3 & diy_callback =? ';
Var data = {
Username: "abc@example.com ",
Users: ['A', 'B']
}
$. Post (url, data );
$. Get (url, data );
$. GetJSON (url_jsonp, data );
</Script>
</Body>
</Html>
Use comparisonCopy codeThe Code is as follows: // After Transformation
$. Post ('/ajax/dir/page/action', {page: 1 })
// Before Transformation
$. Post ('/ajax. php ',{
Dir: 'dir ',
Page: 'page ',
Action: 'action ',
Args: JSON. stringify ({page: 1 })
});