MRRaja
MRRaja

Reputation: 1161

How to retrieve a specific div data using jQuery Ajax

$(document).ready(function(){
  $("button").click(function(){
    $.ajax({url:"A.asp?mmid=1&umid=2" ,success:function(result){
      $("#adfrnd").html(result);
    }});
  });
});

I am trying to retrieve test div from A.asp page if I include

url:"A.asp?mmid=1&umid=2 #test"

it doeasn't work. Any suggestions?

Upvotes: 2

Views: 1827

Answers (4)

Azathoth
Azathoth

Reputation: 582

If you don't have the need to control the comunication you can keep simple like:

$(document).ready(function(){
  $("button").click(function(){
    $("#adfrnd").load("A.asp?mmid=1&umid=2");
  });
});

and remember to use something to debug the calls such as the developers tools provided by Chrome or firebug for Firefox. If you have an error in your a.asp you won't see a thing. Checking the network tabs you see the output provided by yout a.asp call

Upvotes: 1

MRRaja
MRRaja

Reputation: 1161

Working Thanks to every one

$(document).ready(function(){

 $("button").click(function(){    

 $("#adfrnd").load("A.asp?mmid=1&umid=2 #test");    

 });

});

Its Works.... :)

Upvotes: 0

Jude Duran
Jude Duran

Reputation: 2205

As for your comment in T.Stone's post, you just want to print the text "success". If that is so,, then why don't you just hard-code it like this?

success: function(resultHtml) {
  $("#adfrnd").html("success");
}

or did I misunderstood your comment?

Upvotes: 0

T. Stone
T. Stone

Reputation: 19495

You can use jQuery to wrap the resulting HTML andthen find or similar from within that.

success: function(resultHtml) {
  $(resultHtml).find('.whatever-class').html() // then use this for whatever
}

Upvotes: 3

Related Questions