tags:

views:

88

answers:

2

hi everybody,

I have a page with a div, inside this div I load a page with a form with a select, I can get selected option by post() function but, how can I get at the same time selected option and full data option? I've tried to get full data with a post() in a click() function positioned directly on form page but it does not work, can I post 2 times on the same page(one for get selected option and one for full data option)?

thanks in advance

ciao, h.

+1  A: 

I would use post to get all the options and then in the success function make another ajax post call to get the selected option. This way you can ensure all the options are loaded before trying to set the selected option.

AdmSteck
@Nick Craver and Rob Lund: thanks for answering! I have to get at the same time all opions values and the option selected. @AdmSteck That's seems what I'm looking for, now I have to test it! thanks.
haltman
+1  A: 

If you are trying to load different portion on a page you can try this

  1. Create a page with all the contents you want to load, and seperate the contents with a switch for example "content.php"

    <?
    $key = $_POST['key'];
    switch($key) {
             case "news":
                  echo '<div id="news">.............News Content.............</div>';
                  break;
             case "link":
                  echo '<ul> 
                            <li> <a href="home.html">Home</a> </li> 
                            <li> <a href="aboutus.html">About us</a> </li> 
                        </ul>';
                  break;
             default:
                  echo "Sorry, the content is not available.";
                  break;
    }
    ?> 
    

Then afterwards in the page where you make calls do something like this

$(document).ready(function() {
     $("#menudiv").load("content.php", { key: 'link' });
     $("#newsdiv").load("content.php", { key: 'news' });

 });
Starx
@starx thanks for answering, that's a good idea but I've to do different things.
haltman
What different things?
Starx
@Starx if you read AdmSteck's answer you'll understant what things I speak about thanks again ciaoh.
haltman