Hello everyone, I'm developing a Qt program that contains an OpenStreetMap application as a HTML page and this page is able to access a database -via submitting an ajax form that contains the start and end dates of queries- in order to retrieve and visualize queries on the map. I would like to move this querying process to Qt from the HTML/Javascript part. So far I managed to interact with the browser via Qt but I still have a problem that is below: (by the way, the database is a MySQL database on XAMPP and trying to fetch queries from the HTML window's fetch button works -although it also sometimes shows the POST failed message and then clicking again fetches and shows the queries, I haven't been able to figure that out either-)

1) The fetch queries button of Qt is clicked and an alert box is supposed to pop up saying that Ajax POST is failed -the database is not on my current laptop and I should be getting the error when I click either the HTML Browser window's fetch queries button or the Qt's fetch button-

2) But also, whenever I click the Fetch queries button of the HTML Browser, it displays the POST warning but also displays extra POST warning alert boxes depending on how many times I have clicked the Qt's Fetch queries button. -for example if I have clicked the Qt's fetch queries button 5 times in a row and then clicked the HTML window's fetch button once, I get 6 POST failed messages in a row-

The HTML code is like the following:


Qt Code:
  1. <form id="ajaxForm" action="index.php" method="post">
  2. Start <input type="text" name = "date1" id = "datepicker" value = "2011-07-13" style = "width:70px">
  3. <input type="text" name = "time1" id = "timepicker1" value = "00:00" style = "width:40px">
  4.  
  5. End <input type="text" name = "date2" id = "datepicker2" value = "2011-07-13" style = "width:70px">
  6. <input type="text" name = "time2" id = "timepicker2" value = "00:01" style = "width:40px">
To copy to clipboard, switch view to plain text mode 





The post method of AJAX form is this:



Qt Code:
  1. <script type="text/javascript">
  2.  
  3. $(document).ready(function(){
  4.  
  5. // ajaxForm submit
  6. $('#ajaxForm').submit(function() {
  7. $.ajax({
  8. type: 'POST',
  9. url: 'heatQuery.php',
  10. data: $(this).serialize(),
  11. dataType: 'json',
  12. success: function(response)
  13. {
  14. // update the points for heatmap layer
  15. updateHeatMap(response);
  16.  
  17. },
  18. error: function(errorMsg)
  19. {
  20. alert('Error in Ajax POST');
  21. }
  22. });
  23.  
  24. return false;
  25. });
  26. });
  27.  
  28. </script>
To copy to clipboard, switch view to plain text mode 





And finally, the Qt code that calls the function is this:




Qt Code:
  1. void MainWindow::onButtonClicked() // clicking the button in order to POST
  2. {
  3. //the QString a is the same ajax post function as declared above
  4.  
  5. QString a = "$(document).ready(function(){$('#ajaxForm').submit(function() {$.ajax({type: 'POST',url: 'heatQuery.php',data: $(this).serialize(),dataType: 'json',success: function(response){updateHeatMap(response);},error: function(errorMsg){alert('Error in Ajax POST');}});return false;});});";
  6.  
  7. this->view->page()->mainFrame()->evaluateJavaScript(a);
  8.  
  9. }
To copy to clipboard, switch view to plain text mode 



Any ideas on what is wrong here? Thanks.