-1

I have an url in ajax like this:

<html>
<header>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</header>
<body>
<?php 

        echo("<pre>");
        echo "Hello: <span style='color:red'>".$user_data['user'];
        echo("</pre>"); 
        echo "<button  id='play' id_user = '".$user_data['id']."' user = '".$user_data['user']."'>Chơi game</button>";
?>

<script>
$("#play").click(function(){
    var user_id  = $(this).attr('id_user');
    var user = $(this).attr('user');
    window.location=  "<?php echo site_url('wellcome?user_id='.$user_data['id'].'&user='.$user_data['user']); ?>";

    })
</script>
</body>
</html>

When i redirect to welcome Controller with 2 parameters then it shows a 404 error. How should i do pass that parameter to controller welcome? Thanks all!

codewitharefin
  • 1,398
  • 15
  • 24
mrdragon
  • 247
  • 1
  • 2
  • 14

1 Answers1

0

Things to check for the redirect (not ajax) you are trying to do:

  • use window.location.href
  • are you certain, there's something at wellcome?... (welcome typically has a single letter l ?
  • check in HTML source view, what get's generated behind the equal sign. Does it look like a reasonable URL path?
  • obviously, you attempt a relative path, see further advice here how to do that.
  • Arguably better, change to an absolute path, using PHP $_SERVER Variables to glue it together, or at least start with a leading // (path and protocol-relative to your page)
Community
  • 1
  • 1
Frank N
  • 9,625
  • 4
  • 80
  • 110