Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
120
rated 0 times [  127] [ 7]  / answers: 1 / hits: 8804  / 11 Years ago, tue, december 17, 2013, 12:00:00

this is my code snippet



      jQuery('select[name=' + element + ']').html('<option value=>Select</option>');
jQuery.each(data, function(key, value) {
jQuery('select[name=' + element + ']')
.append(jQuery(<option></option>)
.attr(value, key)
.text(value));
});


and this is the array that i am getting from response



   {1:470 - MAJOR JOINT REPLACEMENT OR REATTACHMENT OF LOWER EXTREMITY W/O MCC,2:885 - PSYCHOSES,3:897 - ALCOHOL/DRUG ABUSE OR DEPENDENCE W/O REHABILITATION THERAPY W/O MCC,4:885 - PSYCHOSES,5:470 - MAJOR JOINT REPLACEMENT OR REATTACHMENT OF LOWER EXTREMITY W/O MCC}


and i am getting this error, i dont know why i am getting this error TypeError: invalid 'in' operand obj



EDIT : TO remove confusion i am posting the function with which i am sending request as follows:



        function  fetchValuesForDrgDefinition(url,drg) {
jQuery.ajax({
type: json,
url: url,
}).success(function(data) {
appendOptionsInSelectBox(drg,data);
});

}

More From » jquery

 Answers
8

Make sure you set dataType: 'json' in your jQuery ajax request.


[#49447] Tuesday, December 17, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
makaylahh

Total Points: 128
Total Questions: 106
Total Answers: 97

Location: Tanzania
Member since Wed, Feb 24, 2021
3 Years ago
;