I need a bit of help with PHP and JQuery. How would I go about passing a variable from PHP to JQuery while at the same time redirecting to another page that accesses the JQuery in the front end? Any help will be very much appreciated. I need the systemFeedBack to be sent when I redirect
Mysql::runAdhocQuery($insert_sql, $link);
echo MyClass::systemFeedBack(202, "Registration successful", "User can Log in");
header("Location: http://localhost/myProject/#/");
Asked
Active
Viewed 52 times
0

BrodaTherapy
- 91
- 2
- 11
-
what you tried? any code? – Gokul Shinde Feb 18 '16 at 09:01
-
Yeah, I tried echoing and returning. Afterewards using the Header(); but nothing – BrodaTherapy Feb 18 '16 at 09:03
-
Please post your code then...done – William Madede Feb 18 '16 at 09:03
-
cool lemme put it up – BrodaTherapy Feb 18 '16 at 09:11
1 Answers
2
Since you would be passing the variables via url you can either get the variables using Jquery or Javascript. Below is a pure JavaScript code to GET the query params.
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
// query string: ?foo=lorem&bar=&baz
var foo = getParameterByName('foo'); // "lorem"
var bar = getParameterByName('bar'); // "" (present with empty value)
var baz = getParameterByName('baz'); // "" (present with no value)
var qux = getParameterByName('qux'); // null (absent)

Community
- 1
- 1

Sharan Mohandas
- 861
- 1
- 9
- 25