call and post value webservice with jquery mobile or phonegap

廉价感情. 提交于 2020-01-07 04:00:48

问题


i desing my page with jquerymobile and i do native app for android with phonegap. it is working but in my page i have form and i have to get some value and after that i will send value/data with webservice. How can i do that ? i research about that but i found some documents these are so complex and not working. so do you have some exapmle/sample ? Thanks


回答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 = data in json format PublishUrl = url where you need to call the service

This same can be used to post and call too, you can change type to "GET" and loop through in your success block




回答2:


Submit form data on click button add following code

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;


来源:https://stackoverflow.com/questions/20329295/call-and-post-value-webservice-with-jquery-mobile-or-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!