AJAX showing retrieved values as undefined

前端 未结 5 1703
暗喜
暗喜 2021-01-21 00:17

I am using AJAX to send values to PHP and retrieve the values from PHP. The problem is the value i am getting from PHP is viewed as undefined in AJAX. Please help me solve this

5条回答
  •  有刺的猬
    2021-01-21 00:29

    again!!! anyways let me explain...

    first you are sending channel by get method in ajax...

    data:({channel:channel}),  //here which is just a vairable global variable 
                               //and not assigned any value in your given code... 
    

    so this send channel as empty... and hence your quesry won't work coz that becomes..

    $query = "select * from '' "; <-- here you have a singe quote `'` which also gives error
    

    secondly..ajax has type properties and not method..

     type:"GET" //here type is get not method
    

    seeing your php and query .. $channel looks like a tbalename and if it is OVERALL then you can just pass the string in you ajax and if not then you have to assign a tablename to channel in ajax

     type:"GET" //here type is get not method
     data:{channel:"OVERALL"}, //note you don't need an extra bracket here `()`
    

提交回复
热议问题