Tag: jersey

将字符串响应(使用HTMLTags)绑定到iframe

我对rest端点进行了ajax调用,它返回HTML标记作为字符串响应。 现在我需要将它绑定到iframe。 这里的数据有html标签之类的 var data=”iFramhi” 我尝试过document.getElementById(‘iframeid’).src=data 我也试过了 $(‘#iframeid’).contents().find(“html”).append(data); 谢谢

jquery $ .ajax跨域GET工作但不是POST

我无法弄清楚为什么GET跨域请求正在工作,但使用完全相同的服务器URL的POST请求不是。 我在服务器上设置了以下响应头(使用JERSEY),用于所有请求方法(GET,POST,PUT,DELETE和OPTIONS): header(“Access-Control-Allow-Origin”, “*”) header(“Access-Control-Allow-Credentials”, “true”) header(“Access-Control-Allow-Methods”, “GET, POST, PUT, DELETE, OPTIONS”) header(“Access-Control-Allow-Headers”, “accept, origin, authorization, content-type, content-length, connection, x-requested-with, user-agent”) GET请求正在跨域工作 $.ajax({ type:”GET”, url: base_url + “workoutdays?memberId=100350194”, beforeSend: function(xhr) { xhr.setRequestHeader(“Authorization”, auth); }, success: function(msg) { $(‘#results’).html(msg[0].workoutName); }, error: function (xhRequest, errorText, thrownError) { alert(errorText); } }); 但POST请求不是 $.ajax({ type:”POST”, url: base_url + “workoutdays?memberId=100350194”, […]

415尝试在Jax-RSjersey中发送FormData()时的状态

我正在尝试使用jquery ajax发送附加到FormData的文件。 在介绍了一些mozilla和IBM的文档之后,我想出了以下内容。 ajax代码: var sessionId = $.cookie(“referenceId”); var myFormData = { sessionId: sessionId, cipherData: cipherData, // Encrypted xml data payslip: document.getElementById(‘payslip’).files[0]}; var formData = new FormData(); for (var key in myFormData) { console.log(key, myFormData[key]); formData.append(key, myFormData[key]); } $.ajax({ url : ‘api/rootpath/childpath’, type : ‘POST’, processData: false, contentType: false, // Here the contentType is set […]

HTTP状态415 – JQUERY中的AJAX调用不支持的媒体类型使用JERSEY实现的Restful WS

嗨,我正在尝试将json数据发布到使用Jersey实现的Restful WS。 我通过jquery-ajax发布数据。 为什么我要使用HTTP Status-415不支持的媒体类型? 谢谢。 点击此处查看firebug描述的屏幕截图 //post method handler @Path(“/newentry”) public class NewEntry { @POST @Consumes(MediaType.APPLICATION_JSON) public Response newEntry(String data) { //doStuff } } // ajax call $.ajax({ url: “http://localhost:8080/FirstRestWebService/rest/newentry”, type: “post”, data: formToJSON(), dataType : “json”, success: function(data){ alert(“success”); }, error:function(jqXHR, textStatus, errorThrown) { alert(“failure”); } }); function formToJSON() { return JSON.stringify({ “name”: […]

“Access-Control-Allow-Origin:*”对REST Web服务没有影响

我从JavaScript客户端(在机器A上运行)到Web服务器(在机器B上运行)进行AJAX调用。 客户端尝试访问由RESTful Web服务(Jersey)公开的URL,并且它被阻止并显示错误: Access-Control-Allow-Origin不允许使用原始http:// localhost / 在服务器中,我添加了2个标头参数,允许访问任何客户端。 但它没有帮助: @Context private HttpServletResponse servlerResponse; @POST @Path(“testme”) public void test(){ servlerResponse.addHeader(“Access-Control-Allow-Origin”, “*”); servlerResponse.addHeader(“Access-Control-Allow-Credentials”, “true”); } 对于JSP,相同的头文件有效: test jsp test 我错过了什么吗? 谢谢 PS客户端部分是: $.ajax({ type: “POST”, url: “http://localhost:8080/login/testme”, dataType: ‘json’, success: onLoginSuccess, error: onLoginError });