【问题标题】:What is the correct syntax for this json/jquery call?这个 json/jquery 调用的正确语法是什么?
【发布时间】:2012-10-15 03:34:00
【问题描述】:

我正在使用 phonegap 并在页面上进行搜索。表单中的 id 是 mysearch,应该放在 $.get 调用的末尾。我知道调用是正确的,因为我可以将它放在浏览器中并以 json 格式获取所需的输出。问题是我在表单中输入的内容并没有最终进入通话。在通话结束时,我的语法可能不正确。任何帮助将非常感激。表单代码和调用如下。

    <form action="searchresult.html" method="post">
    <input type="search" name="mySearch" id="mySearch" data-mini="true" data-   theme="b" style="color:#888;"
    value="" onfocus="inputFocus(this)" onblur="inputBlur(this)" autocorrect="off" autocomplete="off" autocapitalize="off" />
    </form>

    <script>
     $("#resultPage").live("pageshow", function (){
       $.get("http://www.test.net/jquery/test.cfc?method=getsearch&returnformat=json&searchName=" + $("#mySearch").val(), {},  function(res) {

【问题讨论】:

    标签: jquery json cordova syntax


    【解决方案1】:

    尝试使用 .on insted .live (因为此方法已弃用)

      $.get("YOUR URL", function(res) {
       // implement logical
    }, 'JSON').error(function(){
       alert('Http error'); // protocol error like 404
    });
    

    【讨论】:

    • 我尝试将其更改为 .on 而不是 .live 但这也不起作用。谢谢你的建议。
    • 你用的是什么版本的jQuery?
    • 我正在使用 jquery-1.7.2.min.js。
    • 试试这个测试$('#resultPage').on('pageshow', function (event, ui) { console.info(event); console.info(ui); });这个事件被触发了吗?
    • 我在这个应用程序中多次使用相同类型的呼叫,我没有遇到任何问题。我想试试你的建议,但我是编码的初学者。我不确定我应该为 (event,ui) 放什么。这和通话一样吗?我为我的困惑道歉。再次感谢您的帮助。
    猜你喜欢
    • 2014-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-22
    • 2021-10-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多