Note that there are some explanatory texts on larger screens.

plurals
  1. POI can't @POST data from a javascript client to a jersey WS
    primarykey
    data
    text
    <p>i'm working on a project based on jersey (server) and sencha touch (client : javascript)...when i tried to make some GET calls using Ext.Ajax requests i didn't succeed,so i solved to problem using Ext.JSONP requests and i could get all kind of data from the DB and show them on my Android phone...Now i should make diferent calls with POST method,so i prepared the server part as shown :</p> <p>myresource class :</p> <pre><code>@Path("/myresource") @Component @Scope("request") public class MyResource { ///// Here where spring IoC is used,thanks google :D !! special thanks to Alex !!!! @Autowired VenteService venteService; @POST @Path("/save") @Consumes("application/json") public String addForm(final Form form){ Form fme = new Form(); fme.setNom(form.getNom()); fme.setPrenom(form.getPrenom()); venteService.save(fme); return "walou"; } } </code></pre> <p>the Form class :</p> <pre><code>@XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement @Entity @Table(name = "FORM") public class Form { private String nom; private String prenom; @XmlElement public String getNom() { return nom; } public void setNom(String nom) { this.nom = nom; } @XmlElement public String getPrenom() { return prenom; } public void setPrenom(String prenom) { this.prenom = prenom; } } </code></pre> <p>But unfortunately when i make the Ajax.request :</p> <pre><code> Ext.Ajax.request({ url: 'http://localhost:8082/Module-ReportingPost/webresources/myresource/save/', method:'POST', headers: { 'Content-Type': 'application/json' }, params: JSON.stringify(formsave, null, 2) }) </code></pre> <p>i got this error :</p> <pre><code>XMLHttpRequest cannot load http://localhost:8082/Module-ReportingPost/webresources/myresource/save/. Origin null is not allowed by Access-Control-Allow-Origin </code></pre> <p>Thanks for help guys.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload