Reputation: 27038
i have a function like this:
$("#join").colorbox({
onComplete:function(){
// add code here
},
width:"530px", height:"500px", inline:true, href:"#add"
});
what i would like to do is onComplete:function()
to create a ajax request to a xxx.php
file.
i just want to make the request so that i can call a new url. i dont want to load anything from the new file and i dont want to redirect to that file, i just want to make a ajax call to it.
any ideas? thanks
Upvotes: 0
Views: 174
Reputation: 2549
Using the $.ajax function. Like this:
$.ajax({
url: 'myurl.php'
});
Won't this work?
Upvotes: 0
Reputation: 69905
Use $.get
If you want to send anything to this page send in the second param
$.get("xxx.php", {});
Upvotes: 0
Reputation: 3610
If that is all you need, just do a $.get("xxx.php"); in you onComplete function.
Upvotes: 0
Reputation: 1265
$("#join").colorbox({
onComplete:function(){
$.ajax({
url: "xxx.php",
type: "POST",
data: "param1=value"
success: function(){
alert("success");
}
});
},
width:"530px", height:"500px", inline:true, href:"#add"
you can reference jquery's .ajax() method. http://api.jquery.com/jQuery.ajax/
Upvotes: 0
Reputation: 141839
You can use $.get()
to send a GET request to your page. It will look like this:
$.get('xxx.php');
You can use the additional arguments to send data through GET, and to include a callback function if you want to do anything when the request finishes.
Upvotes: 0
Reputation: 218818
You would use the jQuery $.ajax
function. Since you say you don't want to do anything with the response, you can just have an empty function for the success
parameter of the .ajax()
call. (Though I recommend against doing nothing with the response. You should at least check that it's good, even if you don't present anything to the user. Definitely don't ignore responses in the error
parameter.)
Upvotes: 0
Reputation: 15003
Take a look at: http://api.jquery.com/jQuery.ajax/
$.ajax({
type: "GET",
url: "xxx.php",
success: function(msg){
alert("Success!");
}
});
Upvotes: 4