• Register
Welcome to Kodlogs, programming questions and answer website.
+1 vote
78 views

i want to add some string to the url in ajax process, but fail every time i access the function. when i submit the form it only access this url 'Master_data/'

var jenis_submit = document.getElementById('jenis_submit');
            var submit_url = '';
            if(jenis_submit == '1'){

                submit_url = "func_save_instansi";
            }else if(jenis_submit == '2'){

                submit_url = "func_update_instansi";
            }

            $.ajax({
                url: '<?php echo base_url();?>Master_data/'+ submit_url,
                method: 'POST',
                data: dataKirim, 
                contentType: false,
                cache: false,
                processData: false,
                success:function(data){
                    // console.log(data);
                    $('#notif').html(data);
                }
            }
by (9.7k points)  
reopened by

1 Answer

+1 vote
jQuery(document).ready(function($) {

   var PostCode=1;
   $.ajax({ url : "http://SomeAddress.com/"+PostCode +".json",
   dataType : "jsonp"
   //.... more stuff
  });


  $("#SetPostCode").click(function() {
     PostCode = document.getElementById("GetPostCode").value;
     $("#GetPostCode").val(" ");
     return false; 
  });

});

Above would work as PostCode is now global to the jQuery and can be accessed anywhere

by (540 points)  
...