Note that there are some explanatory texts on larger screens.

plurals
  1. POPosting to a PHP script with Ajax (Jquery)
    primarykey
    data
    text
    <p>I have an application that I'm writing that, in one aspect of it, you click on a checkmark to complete a task, a popup window is displayed (using bootstrap), you enter your hours, and then that is sent to a PHP page to update the database. I'm using FF (firebug) to view the post. It's coming up red but not giving me an error. The only thing I'm doing is echoing out "sup" on the PHP page, and it's still showing errors, and I can't figure out why. </p> <p>This is my initial click function:</p> <pre><code>$('.complete').on('click', function(event) { var id = $(this).attr('data-id'); var tr = $(this).parent().parent(); var span = $(tr).children('td.task-name'); var r = (confirm('Are you sure you want to complete this task?')); if (r){ addHours(id); } else { return false; } // end else }); </code></pre> <p>That works fine, and it fires my next function which actually fires the bootstrap modal:</p> <pre><code>function addHours(id) { var url = 'load/hours.php?id='+id; $.get(url, function(data) { $('&lt;div class="modal hide fade in" id="completeTask"&gt;' + data + '&lt;/div&gt;').modal() .on('shown', function() { pendingTask(id); }); // end callback }).success(function() { $('input:text:visible:first').focus(); }); } // end function </code></pre> <p>This is also working, and the modal is displayed just fine. However, whenever I post the form to my logic page, it fails for no reason. This is the function to post the form to the logic page:</p> <pre><code>function pendingTask(id) { $('.addHours').on('click', function(event) { var formData = $('form#CompleteTask').serializeObject(); $.ajax({ url:'logic/complete-with-hours.php', type: 'POST', dataType: 'json', data: formData, success: function(data) { if (data.status == 'error') { $(this).attr('checked', false); //location.reload(); } // end if else { $(this).attr('checked', true); //location.reload(); } // end else }, dataType: 'json' }); }); // end click } // end function </code></pre> <p>When this is fired, I see this in my Firebug console: <img src="https://i.stack.imgur.com/6srMt.jpg" alt="There is no error code from the console, and remember the only thing on that page is echo &quot;sup&quot;; so it&#39;s not like I&#39;m trying to execute PHP code that is erroring out."></p> <p>I know this is a lot of information, but I wanted to provide as much information as I could. Every other post function in the application is working fine. It's just this one. Any help would be appreciated. </p> <p>Thanks in advance. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload