There is an object:
var url = { first: "/url/to", second: "/url/to/2" } There is a function:
var GetUrl = function(type){ return url[type] } And there is a code:
<div data-ajax data-load="name, type"></div> var $block = jQuery('[data-ajax]'); var $data = $block.data('load').split(','); jQuery.ajax({ url: GetUrl($data[1]) + $data[0], type: "get", dataType: "html", success: function (template) { StopSpinner(); // hide the spinner $block.html(template); }, error: function (error) { $block.html("<p>Произошла ошибка при получении данных</p>"); } }); And in the end, you can not get the value of the url object. Why? After all, in the function GetUrl I pass the index to get the value, but it goes andefind ...
GetUrl($data[1])=>GetUrl(" type"),GetUrl($data[1]) + $data[0]=>"undefinedname"- what would you like to receive as aurlvalue? - Igorfirst urlorsecond url- Raz Galstyandata-load="name, type"- this is what you have in reality in html? - Igorfirst- Alex_01