$(oFind).bind('click',function(){
var oKeyword = $('.locating').val();
if( oKeyword != '' ){
$.ajax({
type:"post",
async:true,
url: "{:U('Reply/index')}",
data:{keyword:oKeyword},
success:function(){
$(oZs).fadeOut("fast");
$(oCx).fadeIn("fast");
}
});
}
});
oFind is a button. After binding a click event to it, send an ajax request to the background and check the console that everything is normal. There are no errors in the parameters and URL.
<?php
namespace Home\Controller;
use Think\Controller;
class ReplyController extends CommonController {
public function index(){
if($_POST){
echo "ddd";
}
}
}
But it just can’t print out ddd? Can you help me find out what’s wrong?
Sister, you don’t have a console, how can you print? success:function(){
Ajax is not used like this. You pass the value, but if you echo something in the index, it cannot be seen on the other side.
You set up a success callback and receive data processing here.
I prefer json For transmission, if you use json, you can echo json_encode your data in the controller
This is embarrassing. Isn’t the returned data a return? ? ? ? ? ? ? ? ? ? Forgive my ignorance