I have a problem including a jsp inside another jsp. I have a jsp with some fields and i'm trying to include it inside another one using ajax.
This is the code of my main jsp:
When the "jobId" select changes, the "jspToChange" is updated with the following function:
The problem is that when the "jobId" select changes, the included jsp displays at the top of the page and not in the position where the "jspToChange" div is.
I hope that you understand my question.
Thanks in advance for your help.
Thank you for your response. What I'm returning is a JSP which has some textfields. I've used that function before and it worked; however, the difference was that i used a table to separate all the elements. For example:
Then, when i called the ajax function the jsp was updated where the div tag ("jspToChange") was and everything was perfect. However, now that i'm not using this table, when i call the ajax function, the jsp always appears at the top of the page and not where the div is (after the "select"). The thing is that i think that using this table is not good at all because i should use css instead. What i tried was using css and setting the "jspTochange" position to absolute, but it didn work.
I want to show you my problem to see if you can help me.
What i have is this:
The red square is the jsp that i need to update, and the blue one is my main jsp (it has a menu, a submenu and some images). If I use a table to separate the elements, when the select value changes this is what happens:
As you can see, it is updated correctly. But, as I said before, I think that using a table is not correct. Then, if I don use a table i get this:
As you can see, whitout the table, it doesn't update the JSP in the correct way. Is there a different method to do this?
Thanks in advance.
Use the debugger in the browser to inspect the DOM. It will show you where the elements actually are in the structure. When not using the table, what do you return?
I used the debugger and i noticed that when the "select" changes, a new table with the updated elements is created, and it's placed at the top, not inside the div tag. But, if I use the table, when the "select" changes, the new table with the updated elements is placed inside the div tag. I return the same JSP in both cases, the only difference is that I use the table to separate the elements in the example that works correctly. The thing is that i don't like using this table, i'd prefer to solve my problem using css.
Is there a way to do what I want without using this table?
Thanks in advance!
Perhaps I'm missing something, but what I see is this:
You start with a div whose id is "jspToChange". Then you execute an AJAX request which replaces that div with something else -- maybe a table, maybe something which isn't a table but we don't know what it is. But at any rate now you don't have anything in your DOM whose id is "jspToChange", so the next time you execute that AJAX request its result would be put into some default location. That could be at the start of the page, I suppose, I don't remember what happens when you use a nonexistent id value there.
Paul Clapham wrote:Perhaps I'm missing something, but what I see is this:
You start with a div whose id is "jspToChange". Then you execute an AJAX request which replaces that div with something else -- maybe a table, maybe something which isn't a table but we don't know what it is. But at any rate now you don't have anything in your DOM whose id is "jspToChange", so the next time you execute that AJAX request its result would be put into some default location. That could be at the start of the page, I suppose, I don't remember what happens when you use a nonexistent id value there.
Yes, you are right. Actually, it puts the result JSP inside a table ("wwformtable"). What i don't understand is why if I use a table to separate the elements in the main JSP it works correctly?
Thanks!
And this is part of my struts configuration file. As you can see, what I do in the ajax request is to call this action to update the JSP that is inside the "jspToChange" div.
Paul Clapham wrote:Perhaps I'm missing something, but what I see is this:
You start with a div whose id is "jspToChange". Then you execute an AJAX request which replaces that div with something else -- maybe a table, maybe something which isn't a table but we don't know what it is. But at any rate now you don't have anything in your DOM whose id is "jspToChange", so the next time you execute that AJAX request its result would be put into some default location. That could be at the start of the page, I suppose, I don't remember what happens when you use a nonexistent id value there.
The html(<some html>) JQuery method replaces the html content of the matched element(s), not the matched element itself.
Here's the api page.
Post by:autobot
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking