0

I have this code

        $.ajax({
            type: "GET",
            url: "/api/forums/getForums",
            contentType: "application/json;charset=utf-8",
            dataType: "json",
            success: function (data) {
                var toAppend = '';
                for (var i = 0; i < data.length; i++) {
                    toAppend += '<option>' + data[i]['Name'] + '</option>';
                    toAppend += '<a href="AddForum.html">Add new forum</a>';
                }

                $("#forums").append(toAppend)
            }
       });

And this is what I get

enter image description here

'Add new forum' should be link but it's not, it's just regular text and I can't click on it. What am I doing wrong?

xena12
  • 17
  • 9
  • 1
    What is `forums`? seems a ` – Satpal Jun 22 '17 at 11:21
  • You cannot have link inside a `select` – Milan Chheda Jun 22 '17 at 11:23
  • If you want to add anchor link in `select option` then check [this](https://stackoverflow.com/questions/2000656/using-href-links-inside-option-tag)! – Prashant Shirke Jun 22 '17 at 11:24
  • yep should specify what the #forums html tag ! – Bourbia Brahim Jun 22 '17 at 11:27
  • Share html too. If you are having multiple elements with id `forums` then consider using class, or use `$("[id='forums']")`. – Prashant Shirke Jun 22 '17 at 11:27
  • @MilanChheda that's was the problem. I replaced it with list so now everything is working fine. Thank you. – xena12 Jun 22 '17 at 11:35
  • But now I have another question. Is there a way I can send that forum's name while clicking on link? I am adding a new topic by clicking on that link, not new forum like I first wrote, that's typo. I need to know forum's name so I know to what forum I am adding new topic. I hope you understand what I'm asking. – xena12 Jun 22 '17 at 11:46

0 Answers0