tags:

views:

33

answers:

2

Hi everyone. I want to know if there is any other way without using a div tag to receive response html when sending parameter whith ajax. I'am asking because when I am building the select in other servlet and returning the result to jsp it receive the responsehtml in a div tag when we use the famous:

x = xhr.responseText;
document.getElementById('param').innerHTML = x;

with param is the id of div tag. Note: <div id="param" style='display:inline'> this works fine when populating ddl but its constraint are multiple for my case.

Thinks.

A: 

Give the id param to any element you want to use instead of the div and response will be shown in that element.

Sarfraz
No I tried it whithout div tag and i give the id of the select tag but it did not work.I think it is impossible without div tag.
kawtousse
So it's ok I found an other way. thinks for your answer anyway.
kawtousse
A: 

If I understand you correct you don't want to have a dummy div element only to be able to place inside a html fragment received from ajax. In this case you can build you element directly and insert befor or after a real DOM element which you already have. The code can looks like following

jQuery('#select_id').remove(); // if not exists this line makes nothing
var htmlfragment = '<div id="select_id">';
htmlfragment += x; // place data with select element received from ajax call
htmlfragment += '</div>';
jQuery(htmlfragment).insertBefore("#myexistingelement");
Oleg