Reputation: 4565
I am using google app engine
self.response.out.write("1")
self.response.out.write("2")
success: function (data) {
}});
Out of curiosity, if the server returns two objects like above instead of only one, how can the success function tell which is which? say string "1" and string "2" have different duties but they are the same type,(I assume if they are the same type, I can use dataType to differentiate them), but there is only one return value:data. what about I want to use string "1" for something and string "2" for something else, how do I extract them individually? btw, I am not working on any specific project, just coding casually for fun and run into this question. Thank you in advance.
Upvotes: 1
Views: 54
Reputation: 527378
Generally what you'd do is return something with more structure, like a JSON object.
You can generate the JSON manually, or using a JSON library like simplejson
.
self.response.out.write('''{ "foo": 1, "bar": 2 }''')
and then...
dataType: 'json',
success: function (data) {
alert(data.foo);
}
Upvotes: 1