I am new to AJAX and PHP. i want to Replace the Variable value to null.
index.php
<script type="text/javascript" src="javascripts.js"> </script>
<input type="submit" value="Set Value" onclick="makeRequest('index.php?testvalue=7', 'get', null); "/>
<input type="submit" value="Unset Value 1" onclick="makeRequest('index.php?testvalue=null', 'get', null); "/>
<h1><?php echo "PHP Test Value: " . $_GET['testvalue']; ?></h1>
Im trying to change the value of $_GET['testvalue']
to null
whenever I hit the Unset Value
button but what is happening is that it doesn't change the $_GET['testvalue']
variable to null but instead of it does something like $_GET['testvalue'] = 'null'
;
It appears to me that it passes null
as a string
.
Only strings can pass from a form request. You could instead pass an empty string and interpret that as null
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With