在javascript中调用php函数,无需等待响应
问题描述:
我知道如何使用$ .ajax。我有一个Codeigniter项目,所以我只是调用:
I know how to use $.ajax. I have a Codeigniter project so I just call:
url:'<?php echo base_url()."somecontroller/somefunction"?>',
这一切OK,但ajax等待响应。我只是想调用的url,因为你会在浏览器中键入它。我不想等待响应,因为控制器执行重定向,然后加载视图。
This is all ok but ajax waits for the response. I just want to the call the url as you would by typing it in your browser. I don't want to wait for the response because the controller does a redirect and then loads a view. Also i need to be able to send some data via POST.
我该如何做呢?
答
您可以使用以下方式发送带有其他参数的异步请求。
You can use the following for sending asynchronous request with additional parameters.
$.ajax({
type: "POST",
url: url,
data: data, // additional parameters
async:true,
success: function(response){
}
});