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/#/");
-
what you tried? any code?Gokul Shinde– Gokul Shinde2016-02-18 09:01:39 +00:00Commented Feb 18, 2016 at 9:01
-
Yeah, I tried echoing and returning. Afterewards using the Header(); but nothingBrodaTherapy– BrodaTherapy2016-02-18 09:03:17 +00:00Commented Feb 18, 2016 at 9:03
-
Please post your code then...doneWilliam Madede– William Madede2016-02-18 09:03:46 +00:00Commented Feb 18, 2016 at 9:03
-
cool lemme put it upBrodaTherapy– BrodaTherapy2016-02-18 09:11:56 +00:00Commented Feb 18, 2016 at 9:11
Add a comment
|
1 Answer
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)
2 Comments
BrodaTherapy
my problem is with the PHP side. Sorry if I wasnt clear
Sharan Mohandas
glad it helped you :)