web services - PhoneGap, jQueryMobile, JSON, ASP.NET WebService ASMX -


i'm creating mobile app for/with phonegap. trying load external data through asp.net web service created myself. web service works correct when run local ripple emulator , url set local web service. moment change url online version, cross-platform, doesn't wor anymore in local ripple emulator, following error:

syntaxerror: unexpected token e   @ object.parse (native)   @ incomingmessage.module.exports (/app/node_modules/express/node_modules/connect/lib/middleware/json.js:76:27)   @ incomingmessage.eventemitter.emit (events.js:93:17)   @ httpparser.parseronmessagecomplete [as onmessagecomplete] (http.js:149:23)   @ socket.socket.ondata (http.js:1825:22)   @ tcp.onread (net.js:404:27)" 

i read lot of possible solutions online cannot seem fix problem. after reading phonegap, jquerymobile , web service thought simple , should work without solution of jsonp, proxies, httphandlers, , such.

below added of code should relevant:

html/javascript

    function onbodyload() {         // add phonegap deviceready event listener         document.addeventlistener("deviceready", ondeviceready, false);     }      function ondeviceready() {         // test function         login();     }      function login() {         try {             // validate credentials             $.ajax({                 type: "post",                 url: 'http://login.multiviewer.nl/mobile.asmx/validatecredentials',                 contenttype: "application/json; charset=utf-8",                 data: '{ username: "x", password: "y", browser: "", title: "", ipaddress: "" }',                 datatype: "json",                 success: function (object) {                     alert("success");                 },                 error: function (em, msg) {                     alert("function error");                 }             });         }         catch (err) {             alert("catch error");         }     }  //--> </script> 

asp.net web service asmx

namespace web.core.webservices {     [webservice(namespace = "http://tempuri.org/")]     [webservicebinding(conformsto = wsiprofiles.basicprofile1_1)]     [system.componentmodel.toolboxitem(false)]     [scriptservice]     public class mobile : webservice     {         [webmethod]         [scriptmethod(responseformat = responseformat.json)]         public string validatecredentials(string username, string password, string browser, string title, string ipaddress)         {             dictionary<string, string> keyvalues = new dictionary<string, string>();             keyvalues.add("something", "ok");             javascriptserializer jss = new javascriptserializer();             return jss.serialize(keyvalues);         }     } } 

phonegap

<?xml version="1.0" encoding="utf-8" ?> <widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="com.multiviewer.app" version="1.0.1" versioncode="1">    <!-- general app settings -->   <name>app name</name>   <description>app description</description>   <author href="http://www.rhainesoft.nl/" email="info@rhainesoft.nl">rhainesoft</author>    <!-- app icon -->   <icon src="images/icon.jpg" />    <!-- features used, rights needed @ installing -->   <preference name="permissions" value="none"/>   <preference name="orientation" value="default" />   <preference name="target-device" value="universal" />    <!-- expose access uris, including file , http protocols -->   <access origin=".*"/>    <!-- content -->   <content src="index.html" />  </widget> 

i appreciate fix problem me. if have questions or if missed please let me know.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -