I've a server side query which generically generated all select box options in the form
<option val='1'> text1 </option>
<option val='2'> text2 </option>
<option val='3'> text3 </option>
<option val='4'> text4 </option>
<option val='5'> text5 </option>
Now I want to convert all of this to a format that jqgrid understands for its dropdowns. i.e. {1:text1, 2:text2....} Condition is that I would not touch the server side code. I need to modify it here at client side by adding a generic function. Now I get this through an jquery ajax call
getGridDropDown: function (url) {
$.ajax({
type: "GET",
url: url,
dataType: "html",
success: function (html) {
$(html).find('option').each(function(key){
alert(key)
})
},
error: function () {
console.log("Error in ajax call to url: " + url);
}
});
},
Now I tried various formats, the only way looks like using regexp is the only way. Can't I handle the html return variable as a jquery variable, where I can say $this.val() + this.text()