Reputation: 43778
Does anyone know how can I post a html without reload the page in jquery or c# .net?
Example:
I have get a urllink in the page with the following link (dial.html?PhoneNumber=0465254245). When I clicked on the link, how can I post this url without reload the page with ajax?
Upvotes: 0
Views: 728
Reputation: 8272
For variety to the other two answers lets use jQuery Get
Request the dial.html?PhoneNumber=0465254245
page, but ignore the return results.
$("YOUR_SELECTOR").click(function(){
$.get("dial.html?PhoneNumber=0465254245");
});
If you want to catch a returned value:
$("YOUR_SELECTOR").click(function(){
$.get("dial.html?PhoneNumber=0465254245", function(returnedvalue) {
alert("Value Returned: " + returnedvalue);
});
});
Helpful links on jQuery AJAX
:
Cheers!
Upvotes: 0
Reputation: 952
The simple way is using the shorthand AJAX call.
$.post('dial.html?PhoneNumber=0465254245', function(data) {
$('.result').html(data); // .result is the class where you want the page to be
});
The long way is the following,
$.ajax({
type: "POST",
url: url, //Your URL
data: data,
success: success,
dataType: dataType
});
Refer here for a comprehensive options, including sample codes.
Upvotes: 1
Reputation: 410
Something like this should work:
$("#link").click(function(){
$.post("dial.html?PhoneNumber=0465254245", function(data){
alert("Post completed");
}
}
http://api.jquery.com/jQuery.post/
Upvotes: 0