Ajax not returning data after post call
I know there are tons of these questions out there but everything I try seems to fail. Im just sending a simple ajax call and expecting to get something back. Instead the call succeeds but I get no data back. Ideas why?
the javascript:
- jQuery(document).ready(function() {
- if(jQuery('#statesel').length) {
- var dataString;
-
- dataString = "nonce=" + dynoselect.post_dyno_select_nonce + "&tbl=state";
- jQuery.ajax({
- type: "POST",
- url: dynoselect.ajaxurl,
- dataType: "json",
- data: dataString,
- success: function(result) {
- alert(result.test);
- }
- });
- }
- });
the php:
- <?php
- function dyno_select() {
- $result['test'] = "HELLO";
- echo json_encode($result);
- }
- ?>