Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,464
    Thanks
    15
    Thanked 0 Times in 0 Posts

    ajax call is not showing correctly

    i'm doing the following on a select box to load the next select box (in a td with the id)



    if I look at the html returned by the ajax call I get

    PHP Code:
    <select name=optionvalue /><option value='test 1'>test 1</option><option value='test 2'>test 2</option><option value='test 3'>test 3</option></select
    but it's showing as

    the select box and then

    test 1test 2test 3


    my javascript code is

    PHP Code:
    function Loadoptionvalueselect() {
            
    //alert("here");
            
    urltoajax "getoptionsvaluesselect.asp?1=1"
            
    strarea document.getElementById('optionid').value;



            
    urltoajax urltoajax '&optionid=' strarea
            urltoajax 
    urltoajax '&rnd=' Math.round(Math.random() * 10000)
            
    // alert(urltoajax);
            
    $.ajax({
                
    urlurltoajax,
                
    cachefalse,
                
    success: function(html) {
                    $(
    "#troptionvalue").html(html);
                }
            });

        } 
    any ideas what could be causing this?

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    Yes it's actually quite simple

    with /> you are closing the select tag already. Just omit the /

  • #3
    New Coder
    Join Date
    Sep 2011
    Posts
    43
    Thanks
    6
    Thanked 6 Times in 6 Posts
    I don't know if this might have anything to do with it, but it looks like your first <select> is being closed before you get to your options:

    [code]
    <select name=optionvalue /> (prematurely closed?)
    <option value='test 1'>test 1</option>
    <option value='test 2'>test 2</option>
    <option value='test 3'>test 3</option>
    </select>
    [code]

  • #4
    Senior Coder
    Join Date
    May 2004
    Posts
    1,464
    Thanks
    15
    Thanked 0 Times in 0 Posts
    thanks you spotted it - that was the problem


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •