Welcome Guest, Not a member yet? Register   Sign In
Help me to create choose regional with mysql and ajax
#1

(This post was last modified: 02-12-2020, 11:55 PM by mjamilasfihani.)

I created an api in my localhost, try call it as https://api.example.test/v1/address/id/parameter

the value of parameter is province, district, sub-district and village.

I have created a country list in my ContinueSignUpView that has a id value. And here is my javascript :

Code:
$(document).ready(function(){

    var baseUrl = 'https://api.example.test/v1/address/id/';
    var id      = $(this).val();

    $('#ajax_country').change(function(){
         $.ajax({
             url      : baseUrl + 'province',
             method   : 'POST',
             data     : {id : id},
             async    : true,
             dataType : 'json',
             success  : function(data){
                 var html = '<option hidden="">Province</option>';
                 var i;

                 for(i=0; i<data.length; i++){
                     html += '<option value="'+data[i].id+'">'+data[i].name+'</option>';
                 }
                 $('#ajax_province').html(html);
             }
         });
    });

       /**
        * Another Javascript (parameter)
        *
        */

});

I have checked that request return as 200, but it cant show the province select, Thanks

I also has added in my api .htaccess :

Code:
Header set Access-Control-Allow-Origin "*"
Reply


Messages In This Thread
Help me to create choose regional with mysql and ajax - by mjamilasfihani - 02-12-2020, 11:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB