Jump to content

common

Members
  • Posts

    58
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

common's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi Thanks for your reply. I tried looking at the website, but had some difficulty to understanding/initialize the Slim app object. So I am not sure if I am doing it correctly now: Can you maybe just help me where I go wrong, or what developing pattern I should follow. Here is something I have already. <?php header("Content-Type: application/json"); require 'Slim/Slim.php'; \Slim\Slim::registerAutoloader(); $app = new \Slim\Slim(); $app->get('/users', 'findAll'); $app->get('/users/:id', 'findById'); $app->post('/user/new', 'create'); $app->put('/user/update', 'update'); $app->run(); function create() { $app = new \Slim\Slim(); $request = $app->request; //Slim::getInstance()->request(); $user->json_decode($request->getBody(),true); $id = .... echo $id; } function update() { $request = Slim::getInstance()->request(); $user = json_decode($request->getBody()); ... } function findAll() { $userarr =... echo json_encode($userarr); } function findById($id) { $user = ... echo json_encode($user); } ?> Thanks in advance.
  2. Hi Sorry, meant javascript - The Base64 is a java object that I found on the internet javascript The token is not a bad idea, but got it to work using var xhr = new XMLHttpRequest(); xhr.open(method, url, true); xhr.responseType = 'blob'; xhr.setRequestHeader('Authorization', 'Basic ' + auth); xhr.onload = function(e) { if (this.status === 200) { var blob = new Blob([this.response], {type: this.response.type}); var blobURL = URL.createObjectURL(blob); blobCallBack(blobURL); } }; xhr.send(); blobCallback is a function I provide where I do my inline content: src=blobURL . And that works perfectly. Thanks for your help!
  3. Hi everyone. I am looking at creating my application's back end with PHP, which returns all data with Jason or simplexml. I have tried Slim once, but think there should be something easier to use. Can anyone give me suggestions on what I can use which is easy to catch on, and maybe an example? Appreciate it. Kind regards
  4. Hi Everyone, I am struggling with a pdf. On our server I get the pdf as a byte array from the database, which I then build up in a StreamingOutput object and return as a pdf file. This is done using java using JAX-RS service. Now when I open the path/link in my browser(chrome/firefox) the pdf opens in the browser. So this means my backend is working. On my webapp I want to use $.ajax to download the pdf and view it in an Iframe or embed it in an <embed> or <object> tag. I need to do this as the service call is actually under username and password, and we do not create a session between the browser and the server - there is a long explanation for this. I saw the option to use http://[username]:[password]@www.myserver.com/... but this was dropped by most browsers. This is why I am trying ajax. Now in my ajax call I do receive the pdf in the success function as: %PDF-1.4.... This open the browser's pdfviewer correctly and every thing, but the pdf only returns blank pages. The Base64 is a java object that I found on the internet. But I have tried it without the base64 but still now luck. Here is my success function from my ajax call. success: function(data, status, xhr) { var pdfText = Base64.encode(xhr.responseText); var url = "data:application/pdf;base64," + escape(pdfText); var html = '<embed width=100% height=600' + ' type="application/pdf"' + ' src="' + url + '">' + '</embed>'; $("div.inner").html(""); $("div.inner").append(html); }, Can anyone help me? Kind regards
  5. common

    Print()

    Hi Guys, I am working on 2 pages. One page has a list of accounts with a form and this is submitted to second page. The second page displays html of documents(like invoices and so on.) that need to be printed. The system I work in is a couple of pages in framesets. Now I want to have the html in the second page printed without showing the second page. So in other words: When the submit button is clicked I need the print box popup and when print is clicked the second page needs to be printed. Now what I have done, is to add a another frame to the frameset with a with of 0, so it will not be visible in the browser. And after the second page loads, I use the window.print() function to bring up the print box. My problem is, that this only works when I open the second page in a new window. And nothing happens when I open the second page in the additional frame. Now I havn't tried thisyet, but belives if I use parent.[framename].print() it will work for the frame. I want it work in both when opening the page in a new window and when I open it in the Additional frames. Does anyone know how I can do this? Thanks in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.