【问题标题】:call and post value webservice with jquery mobile or phonegap使用 jquery mobile 或 phonegap 调用和发布价值 web 服务
【发布时间】:2013-12-02 13:18:03
【问题描述】:

我用 jquerymobile 设计我的页面,我用 phonegap 为 android 做原生应用程序。它正在工作,但在我的页面中,我有表单,我必须获得一些价值,然后我将使用 web 服务发送价值/数据。我怎样才能做到这一点 ?我对此进行了研究,但我发现一些文件非常复杂且无法正常工作。那么你有一些例子/样本吗?谢谢

【问题讨论】:

标签: android jquery web-services cordova


【解决方案1】:
  $.ajax({
    url: PublishUrl,
    type: 'POST',
    data: JSON.stringify(postData),
    contentType: "application/json;charset=utf-8",
    success: function (result) {


    },
    error: function (x, y, z) {
        alert(x.responseText +" "+ x.status);
    }
});

postData = json 格式的数据 PublishUrl = 您需要调用服务的网址

这同样可以用于发布和调用,您可以将类型更改为“GET”并在您的成功块中循环

【讨论】:

  • 我使用 wcf 服务,它给了我 xml =/
【解决方案2】:

点击按钮提交表单数据添加如下代码

var ajax_call = web_service_URL;
var str = $('#frm_id').serialize();;

$.ajax({
   type: "POST",
   url: ajax_call,
   data: str,
   cache:false,
   dataType: "json",
   success: function(response){   



     }
 }).done(function() {

 })
 return false;

【讨论】:

  • 我使用 wcf 服务,它给了我 xml =/
猜你喜欢
  • 1970-01-01
  • 2011-10-19
  • 2010-11-09
  • 1970-01-01
  • 1970-01-01
  • 2013-08-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多