1
I have a requisition Ajax
that gets the data I need from a WebMethod
. The problem is that the parameter used for the request is "coming" truncated in the WebMethod
the length of the parameter is 44 digits.
Sent parameter: 31161102996615000145550000000413281487877818
.
How it’s coming: 3.1161102996615E+43
Ajax code:
var valorCampo= $(this).attr('data-clipboard-text');
var content = "parametroConsulta=" + encodeURIComponent(valorCampo);
$.ajax({
type: "GET",
dataType: 'json',
async: false,
contentType: "application/json; charset=utf-8",
url: "myPage.aspx/ObtenhaDados",
data: content,
success: function (data) { dadosObtidos(data); },
error: function (data) { falhaConsulta(data); }
});
WebMethod
:
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json, XmlSerializeString = false)]
public static DadosPessoais ObtenhaDados(string valoPesquisa)
{ .... }
Url displayed in Firebug:
http://localhost:61187/ps/myPage.aspx/ObtenhaDados?valoPesquisa=31161102996615000145550000000413281487877818
content
in the Ajax request is a string? Try using number tocontent
andfloat
for signature of the methodObtenhaDados
– Genos
Yes
content
is astring
...– JcSaint
Try to change the shipping method in jQuery to "POST", so:
var content = "{ parametroConsulta: " + encedURIComponent(valorCampo) + " }"
– Douglas Garrido
Too large a number, it is being converted to a readable basis. If you give a
alert(31161102996615000145550000000413281487877818);
the exit will be3.1161102996615E+43
. It is being converted to scientific notation.– Mauro Alexandre
That’s right, that’s what I’m trying to figure out, so he’s like
string
rsrsrsrsr– JcSaint
With this amount of number I don’t think it works. What you could use with a smaller amount of number would be
Number
andtoPrecision
ortoFixed
. 44 digits is a lot, even for a computer.– Mauro Alexandre