Home > front end >  I can't get a PHP ajax how return values
I can't get a PHP ajax how return values

Time:10-16


Pray god to help give directions

CodePudding user response:

DataType: 'json instead dataType:' HTML '

Perform to the error or what?

CodePudding user response:

reference 1st floor showbo response:
dataType: 'json instead dataType:' HTML '

Perform to the error or what?

To me in the error set a popup window played as a result,,

CodePudding user response:

First changed the request type to get direct access to the PHP browser link is normal,

CodePudding user response:

Feeling is your link problem, confirm you can access to the url

CodePudding user response:

refer to the second floor zxc150339 response:
Quote: refer to 1st floor showbo response:

DataType: 'json instead dataType:' HTML '

Perform to the error or what?

To me in the error set a popup window results played,,

DataType changed?

 error: function (XHR) {
Alert (XHR) status + '\ n' + XHR. ResposneText)
}


What return

CodePudding user response:

async: false

CodePudding user response:

Path to the right? F12 see,
The back-end is a get or post?

CodePudding user response:

reference 1/f, pay treasure to add friends steal energy digging reply:
dataType: 'json instead dataType:' HTML '

Perform to the error or what?
what is this principle?

CodePudding user response:

Brother: not solid basic skills,

Upstairs there are brothers, let use dataType: 'HTML', not wrong, but I don't recommend to do so is not professional,

Suggested use: dataType: 'json'

You can do it

The PHP side:

//normal return parameter
$code=0;
//error return parameter
$code=1;

//return data sets, can be an array, a string, numeric...
$result=1;

$data [
=https://bbs.csdn.net/topics/'code'=& gt; $code,//according to the business here, oneself hold
'data'=$result
];
Echo json_encode ($data);


Ajax front end success that place:
Success: the function (data) {
Var code=data. The code;
Var data=https://bbs.csdn.net/topics/data.data;
If (code==0) {
//return right

} else {
//warning instructional quality return

}


}

  •  Tags:  
  • Ajax
  • Related