3
It is possible to send two JSON at the same time as the parameter value date jQuery.ajax()?
Is there any way to call these two arguments, since I need to call these two json and show on screen?
Follow the code below:
var token = "Xke;
var jsonTipo1 = "{ tipo: 1, numPagina: 1 }";
var jsonTipo2 = "{ tipo: 2, numPagina: 1 }";
$.ajax({
type : "POST",
url : "https://producao-ws.talcoisa.net/api/Produto/conteudo/",
processData : false,
data : json, jsonTipo2,
success : sucesso,
error : errar,
beforeSend : function(xhrObj) {
xhrObj.setRequestHeader("tokenApp", token);
xhrObj.setRequestHeader("Content-Type", "application/json");
},
});
//Ws
// Responsável por chamar metódos responsáveis pelos títulos e imagens que vem do json
function sucesso(jsonTipo1 , jsonTipo2) {
mostrarImagemNaTelaJsonTipo1(json);
mostrarTituloNaTelaJsonTipo1(json);
mostrarImagemNaTelaJsonTipo2(jsonTipo2);
}
function errar(json) {
ToastMessage.showMessage("Fail!");
}
What should these be
jsonTipo1
andjsonTipo2
? The second parameter of callbacksuccess
is thetextStatus
.– André Ribeiro
type 1 refers to those images and type 2 other images, the two are part of the same Json. The idea is to update these images within html.
– Faro
In your callback
sucesso
the parameterjsonTipo2
will contain thetextStatus
returned from the ajax request. Your question is really very confusing. Try to rewrite and say exactly what is going wrong and what is the expected outcome.– André Ribeiro
To send two JSON through the same request, you must merge them through the method Concat(). But you’re confusing what each argument jQuery.ajax() represents. Read the documentation again and see that they are not your JSON. Whatever you "show on screen" will be what the server language sent as output (eg a PHP echo/print).
– Bruno Augusto