No added datainto database, and not shown in table append using AJAX and PHP

前端 未结 3 1286
执念已碎
执念已碎 2021-01-20 10:50

I am still in the same problem in this link here. So, I used the append method. And here is the AJAX code:



        
相关标签:
3条回答
  • 2021-01-20 11:15

    Try changing your data in ajax to this

    data: {'insert_new': 'insert_new', 'selectW': selectW, 'select_at': select_at, 'pay': pay, 'facture': facture, 'select_opt': select_opt},
    

    You are not getting any value because your data variable does't match with the $_request[] variables

    0 讨论(0)
  • 2021-01-20 11:20

    please correct your json data which you are sending to server

     data: {'insert_new': 1, 'selectW': selectW, 'select_at': select_at, 'pay': pay, 'facture': facture, 'select_opt': select_opt},
    

    and in php add a die

     if(isset($_REQUEST['insert_new'])){
         // your code
    
        die(); // just before closing the if to make sure you are not echoing anything more;
     }
    
    0 讨论(0)
  • 2021-01-20 11:23

    [1] Why are you catching value of a button

    var selectW = $('#insert_new').val();
    

    I think there is no need for that.

    [2] Add this before ajax call

    dataString = 'selectW='+ selectW + '&select_at='+ select_at + '&pay='+ pay+ '&facture='+facture+ '&select_opt='+ select_opt;
    

    [3] In ajax call set `data' as

    data: dataString,
    

    instead of

     data: {'text': insert_new, 'text': selectW, 'text': select_at, 'text': pay, 'text': facture, 'text': select_opt},
    

    [4] Why are you catching response, you are not sending any string back from insert_buy.php

              if(response=="success")
              {
    

    as you are not getting return value as "success", else part is getting executed and getting alert message as "No data added".

    0 讨论(0)
提交回复
热议问题