I have eventually managed to implement an Ajax call in my code but I'm slightly confused how to redirect after the call has been made, an example of my script is seen below, I am developing using CodeIgniter.:
<script type="text/javascript">
function myFunction() {
var form_data = $('#form1').serialize();
$.ajax({
type: "POST",
dataType: "text",
url: "testproject/main/test",
data: form_data,
success: function(response){
window.location("http://www.google.com");
}
});
window.alert("sometext");
}
</script>
within my test() php function can I have a redirect? if not how can I pass information back to the JS function to redirect? also as a final question how could I use a query such as this to dynamically load html into my page? (the final question is more me being inquisitive/nosey). Many thanks in advance and please exercise patience as I am a complete newbie!
EDIT: my Ajax query executes without an issue however - my code never executes:
success: function(response){
window.location("http://www.google.com");
}
do I have to return response in php somehow?