2012-02-11 93 views
0

Safari瀏覽器有沒有在Safari 3.2.3(525.29)或者其他的jQuery AJAX $.post()方法的工作?

我想動態地獲取一些信息,當用戶鍵入輸入但它似乎不起作用。

而且,在其它版本的Safari(我只是測試的版本5)這是工作好,也是IE等。

任何人都可以證實我這還是給我關於$.post()的Safari或者更多信息或有關從primefaces jQuery庫的問題?

我真的很感謝你的意見。

EDITED

我使用jQuery庫與primefaces和我有以下,只是一個例子或代碼片段:

// 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": "[email protected]", "phone": "+45 88779900"} 
+2

請出示一個例子。 – powtac 2012-02-11 00:47:42

+0

您可以發佈運行'$ .post()'調用的JavaScript代碼,包括捕獲用戶在輸入中輸入的代碼嗎? – Jasper 2012-02-11 00:56:00

+0

好吧,我更新了一切,請檢查。 – 2012-02-11 03:20:08

回答

0

我會回答我的問題...

問題是不是jQuery的POST,問題是JSON,是不是有一些瀏覽器都兼容,看看這個:

http://caniuse.com/json

和我面臨的Safari錯誤,類似這樣的錯誤出現在開發者控制檯「JSON能夠可變wansn't被認可」。

爲了解決這個問題,你需要使用一個名爲json2.js庫的作品真的很好。 在這裏你可以找到文檔和下載:

https://github.com/douglascrockford/JSON-js