Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. app.post('/SearchDoner', function(request, response) {
  2. var store;
  3. console.log('here');
  4. console.log(request.body);
  5. console.log(request.body.bg);
  6. console.log(request.body.c);
  7. var bg = request.body.bg;
  8. var city = request.body.c;
  9. response.setHeader('Content-Type', 'application/json');
  10. console.log('select txtFullname,gender,email,address,bgp,mno from information where bgp =' +"'"+ bg + "'" + "and city =" + "'" + city +"';");
  11. connection.query('select txtFullname,gender,email,address,bgp,mno from information where bgp =' +"'"+ bg + "'" + "and city =" + "'" + city +"';", function(err, rows) {
  12. response.json(rows);
  13. console.log(rows);
  14. });
  15. });
  16.  
  17. function fetchDoner()
  18. {
  19. var BloodGroup = $("#dpBloodGroup").children("option").filter(":selected").val();
  20. var City = $("#dpCity").children("option").filter(":selected").val();
  21. console.log(BloodGroup);
  22. console.log(City);
  23. $.ajax({
  24. url:"http://127.0.0.1:5000/SearchDoner",
  25. type: "post",
  26. dataType: 'json',
  27. data:({bg:BloodGroup,c:City}),
  28. crossDomain: "true",
  29. success: function (result) {
  30. $.each(result,function(index,obj){
  31. console.log(obj.txtFullname);
  32. $("#DonerInfo_5").append("<tr><td style='color:;background: #FDC68F;''><span>" + obj.txtFullname + "</span></td>" + "<td style='color:;background: #FDC68F;''><span>" + obj.address + "</span></td>" + "<td style='color:;background: #FDC68F;''><span>" + obj.gender + "</span></td>" +"<td style='color:;background: #FDC68F;''><span>" + obj.mno + "</span></td>" +"<td style='color:;background: #FDC68F;''><span>" + obj.email + "</span></td></tr>");
  33. });
  34. var newUrl = 'http://localhost/Blood%20Donation%20Site_1/donerinfo.html';
  35. document.location.href = newUrl;
  36. },error: function (obj, txtStatus, error) {
  37. }
  38. });
  39. }
  40.  
  41. .....
  42. connection.query('select txtFullname,gender,email,address,bgp,mno from information where bgp =' +"'"+ bg + "'" + "and city =" + "'" + city +"';", function(err, rows) {
  43. if (err) {
  44. res.json({type: false, data: err});
  45. } else {
  46. res.json({type: true, data: JSON.stringify(rows)});
  47. }
  48. });
  49. });
  50. ....
  51.  
  52. ......
  53. $.ajax({
  54. url:"http://127.0.0.1:5000/SearchDoner",
  55. type: "post",
  56. dataType: 'json',
  57. data:({bg:BloodGroup,c:City}),
  58. crossDomain: "true",
  59. success: function (result) {
  60. if (result.type == false) {
  61. alert("Error occured:" + result.data);
  62. return false;
  63. }
  64. $.each(JSON.parse(result.data),function(index,obj){
  65. console.log(obj.txtFullname);
  66. $("#DonerInfo_5").append("<tr><td style='color:;background: #FDC68F;''><span>" + obj.txtFullname + "</span></td>" + "<td style='color:;background: #FDC68F;''><span>" + obj.address + "</span></td>" + "<td style='color:;background: #FDC68F;''><span>" + obj.gender + "</span></td>" +"<td style='color:;background: #FDC68F;''><span>" + obj.mno + "</span></td>" +"<td style='color:;background: #FDC68F;''><span>" + obj.email + "</span></td></tr>");
  67. });
  68.  
  69. ......
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement