0

I have a page index.php On index.php i load another page(new_case_form.php) into index.php with AJAX into my div witch have an id of "out" like this.

function new_case(){
                  if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
                        xmlhttp=new XMLHttpRequest();
                        }
                        else {// code for IE6, IE5
                        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                  }
                  xmlhttp.onreadystatechange=function() {
                  if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                        document.getElementById("out").innerHTML=xmlhttp.responseText;
                  }
            }
            xmlhttp.open("GET","new_case_form.php",true);
            xmlhttp.send();
}

On my new_case_form.php file i include a upload file but it doesnt work.

If i just load the new_case_form.php direct in my web browser without go through index.php, it works just fine. But if i call the page with ajax from index.php then it will not work.

Any ideas why?

I dont know if you answer to questions like this but i really need to get this to work. And i havent found any other with this problem. Maybe i google it wrong :)

The upload script is from http://blueimp.github.io/jQuery-File-Upload/

Have a nice day.

Best Regards from Sweden

  • possible duplicate of [Can scripts be inserted with innerHTML?](http://stackoverflow.com/questions/1197575/can-scripts-be-inserted-with-innerhtml) – Quentin May 29 '13 at 20:34

2 Answers2

0

response text has to be <php echo "something"; ?>

don´t know what your php looks like... i think you try to load just plan HTML... this is not possible what i know :)

Sven Delueg
  • 1,001
  • 11
  • 23
0

Why not use jquery for the ajax handler?

$.ajax({url: "new_case_form.php", cache: false}).done(function( html ) { $("#out").append(html);} );

Source: http://api.jquery.com/jQuery.ajax/

  • Thanks, i hope this helps me but i can not figure out how i call the new_case() function? Now i call the function New case How would the a href tag look like? Sorry for the dumb question, but im quite novice at this :) – user1435012 May 30 '13 at 05:10