Did jquery ajax $.post()
method work in Safari 3.2.3 (525.29) or other?
I am trying to get some information dynamicly when user types on an input but It seems to doesn't work.
Also, in other Safari versions (I just tested on version 5) this is working good and also IE and others.
Could anyone confirm to me this or give me more information regarding $.post()
with Safari or maybe information or issues about jquery library from primefaces?
I will really appreciate your opinions.
EDITED
I am using jquery library with primefaces and I have the following, just an example or code snippets:
// 1. I imported a base64.js that has this structure: (This .js is obfuscated for security)
// methods situated at base64.js
var key = "b3NjYXJqY";
function base64key(){
this.key = function(){
return key;
};
}
function decrypt(val){
//method that just plays with the string passed in the parameter (val)
return decryptedString;
}
/****************************************************************************/
/* 2. Data returned in the callback is an encrypted json from java servlet. */
/****************************************************************************/
// value from my input
var identifier = $('#txtid').val();
$.post('MyServlet', {identifier : identifier} , function(data) {
// MyServlet returns 0 if no data, else returns an encrypted json as base64 generated with a key.
if (data != 0) {
// base64key() is a method from base64.js that just return a key (like b3NjYXJqY)
var b = new base64key();
// variable that contains encrypted json as string
var temp = data.replace(b.key().substring(5), '');
// decrypt the json (temp variable)
var json = decrypt(temp).replace(b.key(), '');
// parse the json string
var info = JSON.parse(json);
// fill the inputs with data
$('#txtname').val(info.name);
$('#txtemail').val(info.email);
$('#txtphone').val(info.phone);
});
/**********************************************************************************/
/* 3. Just to have an idea of the "data" structure, this is the decrypted json. */
/**********************************************************************************/
{"name": "Oscar Jara", "email": "oscar@stackoverflow.com", "phone": "+45 88779900"}
I will answer my own question...
The problem was not the jQuery POST
, the problem was JSON
that is not compatible with some browsers at all, take a look at this:
and I was facing an error with Safari and an error similar like this appeared "JSON variable wansn't able to be recognized" in the developer's console.
To solve this you need to use a library called json2.js
that works really good. Here you can find documentation and downloads:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.