javascript - x-editable post value is undefined -


i created x-editable form :

   <a href='#' class='username'    data-pk='<?php echo $key['idca']; ?>'    data-type="text"    data-placement="right"> <?php echo $key['categoryname']; ?> </a> 

then created javascript function handle x-editable form :

    $.fn.editable.defaults.success = function() { $(this).show() };     $.fn.editable.defaults.mode = 'inline';     $('.username').editable({         url:'edit.php',         pk:'1',         type:'text',         send:'always',         ajaxoptions:{             datatype:'json'         },         success: function(response, newvalue) {             window.alert('oke');         },         error: function(response, newvalue) {             window.alert('failed');         }     }); 

and in php create follow :

<?php   $pk = $_post['pk'];  $val = $_post['value'];  $name = $_post['name'];   print_r($_post);   ?> 

but why received message "undefined index pk, value, name" on window alert, means failed posting pk, value, name x-editable..

need helps, thank much

given following html

<a href="#" class="username"     data-pk="<?php echo $key['idca']; ?>"     data-type="text"     data-placement="right" >     <?php echo $key['categoryname']; ?> </a> 

you can use jquery:

$.fn.editable.defaults.success = function() { $(this).show() }; $('#username').editable({     type: 'text',  // optionnal if you've set data-type attribute      pk: $(this).data('pk'), // optionnal if you've set data-pk attribute      url: 'edit.php', // mandatory     title: 'enter username' }); 

this should work as per documentation. there no need $.ajax({}); yourself.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -