Home > Software design >  How to write pretty URL based from data?
How to write pretty URL based from data?

Time:06-06

How to write pretty url from these data? I need something like this https://mywebsite.com/admin/leads/count/data1/data2/data3

Thanks in advance. :)

var x = {data1, data2, data3};

$.ajax({
  url: 'https://mywebsite.com/admin/leads/count/',
  data: x,
    type: 'GET',
    contentType: "application/x-www-form-urlencoded",
    datatype: "json",
    async: false,
    success: function(data){ 
      $("#leads_count").val(data);
      leadsCtr = data;
    }
});

CodePudding user response:

Take url as a string and manipulate it like this

    var x = {data1, data2, data3};
    var string = 'https://mywebsite.com/admin/leads/count/';
    var fstring = string x.data1 '/' x.data2 '/' x.data3;
    $.ajax({
    url: fstring,
    data: x,
    type: 'GET',
    contentType: "application/x-www-form-urlencoded",
    datatype: "json",
    async: false,
    success: function(data){ 
  $("#leads_count").val(data);
  leadsCtr = data;
}

});

  • Related