调用.j文件

论坛: 

  调用方法: $.ajax({
                                async: <请求方式>  false:同步   true:异步
                                type: <请求方式>,   post    get
                                dataType: <数据类型>"json",
                                url: <调用.j文件的URL>,
                                data: {
                                        <参数>
                                },
                                error: function(error, status, text) {
                                        <失败后的操作>
                                },
                                success: function(result){
                                        <成功后的操作>比如:alert("调用成功!");
                                }
                        });

代码:
                // 服务的地址
                var wsUrl = 'http://192.168.1.105:9080/bdposback/webServicesPOS/restBase/addUser2';
                var jsonStr;
                var ajaxData = '{"name": "acb"}';
                $.ajax({
                        "type" : "post",
                        "async" : false,
                        "dataType" : "json",
                        "contentType" : "application/json",
                        "url" : wsUrl,
                        "data" : JSON.stringify(ajaxData),
                        "success" : function(json) {
                                jsonStr = json;
                                alert('OK!');
//                                alert(o.find('return').eq(0).text());
//                                json=$.parseJSON(o.find('return').eq(0).text());
//                                alert(json.istelnet);
                        },
                        "error" : function() {
                                alert('error!');
                        }
                });

dashan 答复于