I'm hoping someone can help me with my design issue. I have index.php:
which contains a javascript piece of code:
<script type="text/javascript">
$(function() {
$.getJSON('http://localhost/getData.php', function(data) {
foo...
index.php also contains a form that updates the screen:
<form action="index.php" method="post" />
<input type="submit" name="action" value="update" /></p>
Now my problem is I need to pass some variables to getData.php to update the screen. getData works fine with the static info, but based upon the choices on the form, the data will change.
What's the best way for me to pass variables?
Or am I designing this incorrectly?
Thanks
My updated javascript looks like this:
<script type="text/javascript">
$(function() {
$.getJSON('http://localhost/getData.php', {
group_value: $('#group_id option:selected').val(),
updatedb_value: $('#update_db_id').val()
}, function(data) {
Then my form looks like this:
<form id="myform" action="index.php" method="post" />
<select id="group_id" name="group">
<option value="0">Atlanta</option>
<option value="1">Chicago</option>
<option value="2">Los Angeles</option>
<option value="3">New York</option>
</select>
<input type="submit" name="action" value="Update" />
<input type="checkbox" id="update_db_id" name="update_db" value="1" />Update DB?<br />
</form>
No matter what I select or check, When ever I click the update button, the JS console shows that
GET http://localhost/getData.php?group_value=0&updatedb_value=1
Any suggestions?
http://localhost/getData.php
to simply/getData.php
- localhost won't work if you deployed this as-is to a real server. That, and unless you're using JSONP, all your URLs should be relative to the root domain anyway. – Tieson T. Apr 30 at 0:48GET http://localhost/getData.php?group_value=0&updatedb_value=1
. – Peaceful_Warrior Apr 30 at 13:17