- phiggins: I have a form which I'll paste below. When I am just doing standard HTML form post (method="post"), things work as I'd expect. The form basically has 3 fields, Resource drop-down, Date Drop Down, and a Check Availability button (Submit). I choose a resource, a date, and click Check Availability (on a date that I know should return true, therefore return data to the user)...but regardless, it returns false.
- Form:
- <body class="tundra">
- <div dojoType="dijit.form.Form" id="<?php echo $block_name?>" name="<?php echo $block_name?>" encType="multipart/form-data" action="/blocks/scheduler/check_availability.php">
- <table style="border: 1px solid #9f9f9f;" cellspacing="10">
- <tr>
- <td><label for="Resource">Resource:</label></td>
- <td><select name="data[<?php echo $bID?>][resource]" id="data[<?php echo $bID?>][resource]" dojoType="dijit.form.ComboBox">
- <option selected></option>
- <?php $sql="SELECT * FROM hubResources";$result=mysql_query($sql);while($row=mysql_fetch_array($result)){$resource=$row['resource_name'];echo "<option>$resource</option>";}?></select>
- </td>
- </tr>
- <tr>
- <td><label for="Date">Date:</label></td>
- <td>
- <input type="text" name="data[<?php echo $bID?>][date]" id="data[<?php echo $bID?>][date]" value="" dojoType="dijit.form.DateTextBox" required="true" />
- </td>
- </tr>
- <tr>
- <td><button dojoType="dijit.form.Button" type="submit" name="data[<?php echo $bID?>][action]" id="data[<?php echo $bID?>][action]" value="Submit">Check Availability</button></td>
- </tr>
- <tr>
- <td><div id="response"></div></td>
- </tr>
- </table>
- </form>
- </body>
- <script> tag with xhrPost:
- <script>
- function sendForm(){
- var form = dijit.byId("<?php echo $block_name?>");
- dojo.connect(form, "onSubmit", function(e){
- e.preventDefault();
- if (form.isValid()){
- var min = 0;
- var resource = dijit.byId("data[<?php echo $bID?>][resource]");
- if (resource.attr('value').length != min){
- var xhrArgs = {
- form: dojo.byId("<?php echo $block_name?>"),
- handleAs: "text",
- load: function(data) {
- dojo.byId("response").innerHTML = "See below for available time.";
- },//closes load: function(data)
- error: function(error) {
- dojo.byId("response").innerHTML = "Error.";
- }//closes error: function(error)
- }//closes var xhrArgs
- dojo.byId("response").innerHTML = "Checking Availability..."
- var deferred = dojo.xhrPost(xhrArgs);
- }//closes if(message<min)
- else
- {
- alert("You must specify a message");
- }
- }//closes form.isValid
- else
- {
- alert("Sorry, you must fill out every field");
- }//closes the alert
- });//closes dojo.connect
- }; // closes function sendForm()
- dojo.addOnLoad(sendForm);
- </script>
- Firebug Post:
- data%5B71%5D%5Bresource%5D=Conference%20Room%20A&data%5B71%5D%5Bdate%5D=2010-08-18
- Firebug Response:
- Sorry, there aren't any available appointments on this day. We are either out of the office, or unavailable.<br />Click on Schedule Appointment again to try another date
- Like I mentioned...the response should have been the available dates, instead it returns false...yet when I don't do this via xhrPost, it returns the available dates =\