JQUERY AJAX Success

JQUERY AJAX Success

Good Evening,

I have been hunting around for a solution to my problem and I cant find one anywhere!
(So if its out there and I have missed it, I am very sorry for wasting any ones time with this post.)

I have an Ajax call (shown below) that calls a php page to return some data pre-formatted into html. The call works fine and the data is returned into the value 'html', I know this (I think) because if I change Line 11 to Alert out the Data I can see it.

My problem is I would like to change the success portion of the Ajax call to point to a dynamic element id of my choosing (As this changes each time its called, and I don't know what it will be). Thus inserting the result into a dynamically assigned location.

As you may have guessed I cant get this to work.

Is this possible, can someone help me get this working. I can provide more code if it helps, but i am hopeful this is enough.

Many Thanks
J

  1. $('#cat_select_div').on('click', 'li', function(){
  2.             var id = '.' + this.id;
  3.             var row_value = $(this).attr('value');
  4.             $.ajax({
  5.                   type: 'GET',
  6.                   url: 'ajax_product_select2.php', 
  7.                   data: 'Level=' + row_value,
  8.                   success: function(html){
  9.                   $(id).html(html);
  10.             }
  11. })