Good afternoon, I have the following problem, I use AJAX to URL requests, the problem is that when I pass an RFC that has among its characters one & only get chain & this before.
Example:
Http://......../Get?RFCRec=P&G5609219R2
this is fine, but when the request arrives, I just get the letter P. I think I can parse to the request string.
My code is:
GetT: function (item) {
//alert(item.value);
$.ajax({
type: "POST",
url: Get + "?RfcRec=" + item.value,
cache: false,
success: function (html) {
$("#Receptor-Rfc").bind('change', function () {
alrdocument.clearTaxPayerReceiverId();
});
}
})
},
some suggestions????
You need to encodeURIComponent(item.value)
. Ampersand & is a special character in URLS that separates multiple query parameters. Your request is being misinterpreted as including two different parameter names: RFCRec
whose value is 'P' and G5609219R2
whose value is empty.
A generic example of a URL that includes multiple query parameters:
http://example.com/index.html?a=5&b=7&c=9
This URL contains three parameters, a, b, and c. The ampersand acts as a separator.
Take a look http://www.w3schools.com/tags/ref_urlencode.asp
You can replace "&" for "%26"
url: Get + "?RfcRec=" + item.value.replace('&','%26')