defunkt / jquery-pjax

pushState + ajax = pjax
https://pjax.herokuapp.com
MIT License
16.73k stars 1.97k forks source link

<script> inside file loaded #626

Closed mQckingbird closed 8 years ago

mQckingbird commented 8 years ago

Hi everyone,

I'm having a problem with PHP I believe, searched all the web & still not be able to figure it out. I have this..

if(pjax()) {
// split the url in / and remove the pjax instance
$slices = explode('/', str_replace('?_pjax=%23unwritten', '',$_SERVER['REQUEST_URI']));
$class = implode(' ', $slices);
// second section (localhost/first/second)
$twoins = no_inyeccion(xss($slices[2]));
// first one and switch (localhost/first)
  switch($slices[1]){
    case 'work':
     // It works..
     print "<script>function asd(){alert('asd'); } </script><a onclick='asd()'>awd</a>";
     // Doesn't work (it reloads the web)
     include("file.php");
    break;
  }
} else { 
?>

Why is happening? With .load() or an ajax get request it works very well :/ I would really appreciate any help