JS Ajax calling PHP and getting ajax call data

前端 未结 3 1774
死守一世寂寞
死守一世寂寞 2021-01-24 22:19

I have a standard javascript ajax call where I\'m setting the data: to json data.

$.ajax({
    type: \"POST\",
    url: BaseUrl + \"User/Login\",    
    //url:          


        
3条回答
  •  走了就别回头了
    2021-01-24 23:05

    data option must be an object or serialized(e.g. "name1=value1&name2=value2") string.So you need to pass like this:

    data: /*object*/{data:'{"apiKey":"c7089786-7e3a-462c-a620-d85031f0c826","appIDGiven":"200","userName":"matt2","password":"pass"}'},
                    // ^-----this is added for $_POST["data"]
    

    or like:

    data: /*serialized string*/'data={"apiKey":"c7089786-7e3a-462c-a620-d85031f0c826","appIDGiven":"200","userName":"matt2","password":"pass"}',
                               // ^-----this is added for $_POST["data"]
    

提交回复
热议问题