This situation in date does not transfer the contents of the variable js, that is, it is data: ({zapros}), should change to data: ({city_id: 2}), but it does not work, tell me, the first time I work with ajax, what I do not this way? The library is connected, the problem is not checked, if you drive in manual data in date, everything works out.

var zapros = 'city_id:2'; $.ajax ({ url:'/tpl/catalog/product_list.php', type:'GET', data:({zapros}), dataType:'html', success: ajax_success }) 

    1 answer 1

    In data we can pass a string or object.

    Example:

     var zapros = 'city_id=2'; // или var zapros = {city_id:2}; 

    Result code:

     var zapros = 'city_id=2'; $.ajax({ url: '/tpl/catalog/product_list.php', type: 'GET', data: zapros, dataType: 'html', success: function(data) { console.log(data); } }) 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>