0
$.ajax({
    type:"get",
    url:"/test/api/?u="+u,
    dataType:"json",
    data:"",
    success:function result(data){
            $("#show").html(data);
        $("#show").show();
       }
});

i don't understand the above code well, especially the success part. i don't know what will be passed to the parameter data. expect someone can explain it to me. thank you.

1
  • May I suggest reading the documentation on the $.ajax method? api.jquery.com/jQuery.ajax Commented Aug 31, 2011 at 1:25

2 Answers 2

1

data will hold the content returned by the url that you sent the request to. If the url you are posting to is another HTML page, the code for the entire page will be stored in data for example.

Sign up to request clarification or add additional context in comments.

Comments

0

In this case data is a javascript object, like a dictionary, list, int, string, etc. because the dataType is json and jQuery auto-convert the response returned by the url to a javascript object.

2 Comments

The line means: Select the element whose ID is "show" and attempt to replace its HTML content (e.g. innerHTML) with the contents of variable data. Presumably data is a string, and more specifically a string that represents HTML markup.
@CoryLarson +1. But it doesn't make sense to use json in this case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.