In my page I have two divs called context and translation and in test1.php I get two strings one is for context the other is for translation areas. I have written as follows but I can not write the values into the two divs, is there a way to that?
$.ajax({
type: "POST",
url: "test1.php",
}).done(function( msg1, msg2 ) {
document.getElementById("context").innerHTML=msg1;
document.getElementById("translation").innerHTML=msg2;
});
The problem here is that
.done()is not going to have your two variablesmsg1andmsg2as it’s parameters.You can either use a traditional jQuery ajax success handler and then get the single response argument out of it or if you want to use deferred syntax, you can use a .success() method which will likewise get the same single response argument from which you would have to retrieve both msg1 and msg2.
Here’s one article with an example using
.success(fn)instead of.done(fn).You can see here that
.done(fn)doesn’t pass the result of the ajax call to the callback like your code is expecting.So, I think you want something like this: