Skip to content Skip to sidebar Skip to footer

How To Write Php Function Inside Javascript Function

i want to call a php function header('Location:http://xx.yy.zz/somthing') inside a javascript function,Like given below. function mUp(obj) { //here i want

Solution 1:

Thats not how it works.

Use:

window.location = "http://xx.yy.zz/somthing";

Solution 2:

Solution 3:

This is something for JavaScript, not for PHP:

<script>functionmUp(obj)
{
    document.location.href = 'http://www.example.com/';
}
</script>

Solution 4:

The code similar to PHP's header()location function:

header('Location:http://xx.yy.zz/somthing');

In javascript is,

location.href = "http://xx.yy.zz/somthing";

Both does the same redirect for the users, but the former one returns a HTTP Status of 301.

Solution 5:

Why don't you use directly the javascript version?

Have a look to window.location object.

Post a Comment for "How To Write Php Function Inside Javascript Function"