开发者

jquery/ajax post() in a posted page

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 p开发者_开发百科age(one for get selected option and one for full data option)?

thanks in advance

ciao, h.


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.


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' });

 });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜