javascript - Ajax return value from php to textbox without posting value to php -


i want value php , set textbox.

here ajax code:

 function docnum(){  $.ajax({         url: 'docnum.php',         datatype: 'json',         type: 'post',         data: {             'json_encode': $('#tanggal').val()               },         success: function(data){             $('#number2').val(data);                   }     }); } 

and here html code

<input type="text" id="number2" name="number2" placeholder="number2" onclick="docnum()" /> 

and here php code docnum.php

      <?php    $counternew="dummyvariable";     print  json_encode($counternew);      ?> 

why $counternew can not set number2 texbox? please me


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -