I have a form that's calculated on the go. (below picture)   So that table gets created with jQuery &amp; Ajax working with PHP. I want to implement a PDF library that can print that correctly. The tricky part is that I don't know the best way to send that whole table (along with CSS of it in header) to an another PHP file through POST method so that file takes it in and places it inside where it needs to go to PDF get created correctly. What's the best way to go about this?  Process for the table is, first enter dates then select company then click view. At this point, the table gets created, once you click to report it is supposed to create a pdf.  Note to whomever marked this question duplicate: Whoever marked this duplicate, did you really read that other ticket? The other one pure HTML + CSS. I am talking here a page created HTML + CSS and manipulated using AJAX and jQuery! I really don't get people who don't read questions and randomly mark them as duplicate, this has nothing to do with that other question!
6979
I have an HTML (not XHTML) document that renders fine in Firefox 3 and IE 7.  It uses fairly basic CSS to style it and renders fine in HTML.  I'm now after a way of converting it to PDF.  I have tried:   : it had huge problems with tables.  I factored out my large nested tables and it helped (before it was just consuming up to 128M of memory then dying--thats my limit on memory in php.ini) but it makes a complete mess of tables and doesn't seem to get images.  The tables were just basic stuff with some border styles to add some lines at various points; : I actually had better luck with this.  It rendered some of the images (all the images are Google Chart URLs) and the table formatting was much better but it seemed to have some complexity problem I haven't figured out yet and kept dying with unknown node_type() errors.  Not sure where to go from here; and : this seems to work fine on basic HTML but has almost no support for CSS whatsoever so you have to do everything in HTML (I didn't realize it was still 2001 in Htmldoc-land...) so it's useless to me.   I tried a Windows app called Html2Pdf Pilot that actually did a pretty decent job but I need something that at a minimum runs on Linux and ideally runs on-demand via PHP on the Webserver.  What am I missing, or how can I resolve this issue?
18084
Im creating a visit/page views counter with ajax,jquery and php, I have been reading a few articles that recommend the use of nonces for data manipulation through ajax, however i am not sure if i need to integrate the use of nonces for my simple counter?  my code looks somewhat like this;  jquery  jQuery.ajax({         type: 'POST',         url: ajaxurl,         data: {action: 'countHits', status: 'true'},         });   php  //ajax functions add_action('wp_ajax_countHits', 'countHits'); add_action('wp_ajax_nopriv_countHits', 'countHits'); function countHits() {      if($_POST['status'] != "") {        $status= $_POST['status'];      if(!isset($_COOKIE['UNIQUEUSER'] &amp;&amp; $status == 'true'){        $uniqueUser= get_option('stats');        $uniqueUser['uniqueUser']+=1;        update_option('stats', $uniqueUser);     } die();  }   So as you can see it is very simple, do I need to use nonces for each ajax request?(i have two separate request in my jquery which return variables one for false one for true) furthermore, if I wanted to implement nonces how would i go about doing that?
123755
I use LWC components in Customer Community. There is datatable component with records and I implemented the function to export selected records in .csv and .pdf.  csv works fine, but I experience the next issue when downloading the file as pdf:   Here is the code I use to create and download the file:  main.js  handleExportAction(evt) {     const selectedFormat = evt.detail.value;     try {         let _file;         let _type;         switch (selectedFormat) {             case 'csv':                 _file = parseToCSV(this.columns, this.selectedRows);                 _type = 'text/html';                 break;             case 'pdf':                 _file = parseToPDF(this.columns, this.selectedRows);                 _type = 'application/pdf';                 break;             default:                 _file = undefined;                 _type = undefined;         }         downloadDataAsFile('Subscription Overview.' + selectedFormat, _type, _file);     } catch(e) {         console.error(e);     } }   service.js - parse&amp;donwloadFile functions  const parseToPDF = (tableCols, rows) =&gt; {     let cols = [];     tableCols.filter(el =&gt; cols.push('&lt;th&gt;' + el.label));      let fileData = '&lt;html&gt;&lt;head&gt;';     fileData += '&lt;title&gt;Subscription Overview&lt;/title&gt;';     fileData += '&lt;body&gt;&lt;table&gt;';     fileData += '&lt;tr&gt;';     fileData += cols.map(col =&gt; col).join('&lt;/th&gt;') + '&lt;/th&gt;';     fileData += '&lt;/tr&gt;';     fileData += '&lt;tr&gt;';     fileData += '&lt;td&gt;Test Data&lt;/td&gt;';     fileData += '&lt;/tr&gt;';     fileData += '&lt;/body&gt;&lt;/html&gt;';     console.log('file: ' + fileData);      return fileData; };  const downloadDataAsFile = (name, type, data) =&gt; { var file = new Blob([data], { type: type }); if (window.navigator.msSaveOrOpenBlob) { // IE10+     window.navigator.msSaveOrOpenBlob(file, filename); } else { // Others     var a = document.createElement("a"),         url = URL.createObjectURL(file);     a.href = url;     a.download = name;     document.body.appendChild(a);     a.click();     setTimeout(function () {         document.body.removeChild(a);         window.URL.revokeObjectURL(url);     }, 0); } };   The body (fileData) variable is for testing purposes, I tried other options but the result was the same.   Probably the issue is in contentType which I set as application/pdf?  I did not find any limitations related to creating pdf files with js. Did someone experienced this issue before?   Thanks in advance.
24574
I would like to know when I should include external scripts or write them inline with the html code, in terms of performance and ease of maintenance.  What is the general practice for this?  Real-world-scenario - I have several html pages that need client-side form validation. For this I use a jQuery plugin that I include on all these pages. But the question is, do I:   write the bits of code that configure this script inline? include all bits in one file that's share among all these html pages? include each bit in a separate external file, one for each html page?   Thanks.
33938
I have one of those "I swear I didn't touch the server" situations. I honestly didn't touch any of the php scripts. The problem I am having is that php data is not being saved across different pages or page refreshes. I know a new session is being created correctly because I can set a session variable (e.g. $_SESSION['foo'] = "foo" and print it back out on the same page just fine. But when I try to use that same variable on another page it is not set! Is there any php functions or information I can use on my hosts server to see what is going on?  Here is an example script that does not work on my hosts' server as of right now:  &lt;?php session_start(); if(isset($_SESSION['views']))     $_SESSION['views'] = $_SESSION['views']+ 1; else     $_SESSION['views'] = 1;  echo "views = ". $_SESSION['views']; echo '&lt;p&gt;&lt;a href="page1.php"&gt;Refresh&lt;/a&gt;&lt;/p&gt;'; ?&gt;   The 'views' variable never gets incremented after doing a page refresh. I'm thinking this is a  problem on their side, but I wanted to make sure I'm not a complete idiot first.  Here is the phpinfo() for my hosts' server (PHP Version 4.4.7):
28181
What is the recommended way to embed PDF in HTML?   iFrame?  Object?  Embed?   What does Adobe say itself about it?  In my case, the PDF is generated on the fly, so it can't be uploaded to a third-party solution prior to flushing it.
116439
I have a VF code below where I am trying to display the related list of an object using  and  command. I am rendering this page as PDF , doing that in my PDF I am unable to see the content in a tabular format. How can I make the content appear in a table?      &lt;apex:pageBlockSection columns="1" title="TECHNICAL ASSESSMENT"&gt;          &lt;apex:repeat value="{!interviewSkillReviews}" var="interview"&gt;              &lt;table border="1" cellpadding="6"&gt;                 &lt;apex:pageblockTable value="{!interview.Skill_review__r}" var="skillreview"&gt;                      &lt;apex:column headerValue="Skill Name"&gt;                                                         &lt;apex:outputText value="{!skillreview.Skill__r.Name}"/&gt;                     &lt;/apex:column&gt;                 &lt;apex:column headerValue="Recommended Level"&gt;                     &lt;apex:outputText value="{!skillreview.Level__r.Name}"/&gt;                 &lt;/apex:column&gt;                  &lt;apex:column headerValue="Rating"&gt;                     &lt;apex:outputField value="{!skillreview.RatingCopy__c}" rendered="{!NOT(interviewerMode)}" /&gt;                     &lt;apex:selectList value="{!rating}" multiselect="false" size="1" rendered="{!interviewerMode}"&gt;                         &lt;apex:selectOption itemValue="1" itemLabel="1"/&gt;                         &lt;apex:selectOption itemValue="2" itemLabel="2"/&gt;                         &lt;apex:selectOption itemValue="3" itemLabel="3"/&gt;                         &lt;apex:selectOption itemValue="4" itemLabel="4"/&gt;                         &lt;apex:selectOption itemValue="5" itemLabel="5"/&gt;                     &lt;/apex:selectList&gt;                 &lt;/apex:column&gt;                  &lt;apex:column headerValue="Rating Level Description"&gt;                     &lt;apex:outputText value="{!skillreview.Skill_Level_Description__c}"/&gt;                 &lt;/apex:column&gt;               &lt;/apex:pageblockTable&gt;         &lt;/table&gt;      &lt;/apex:repeat&gt; &lt;/apex:pageBlockSection&gt;   I tried using &lt;table&gt; command of HTML but I just get a border around the pageblocktable.    Example of table look and feel:
35807
I have created a VF page and used "render as pdf"  &lt;apex:commandButton value="Save to Opportunity" action="{!savePdf}"  /&gt;   Its working fine when i am using above line without rerender and oncomplete but when i am adding rerender or oncomplete it is not working.I am able to save the PDF in attachment folder but when i am trying to open its showing  "Unable to load document"  Even if i remove oncomplete and use Rerender then also its saving the attachment in Attachment object and when i view ,it is not loading and says "Unable to load document"      &lt;apex:commandButton value="Save to Opportunity" action="{!savePdf}"  oncomplete="myClose();"/&gt;   Javascript Code  function myClose(){      self.close();     window.opener.location.href="/{!$CurrentPage.parameters.Id}";  }   Class Code  public void savePdf() {      PageReference pdf = Page.GenerateQuotePDF;     pdf.getParameters().put('id',parentId);      Attachment attach = new Attachment();      Blob body;     body = pdf.getContent();     attach.Body = body;     attach.Name = 'Opportunity'+ '.pdf';       attach.IsPrivate = false;     attach.ParentId = parentId;     attach.ContentType = 'application/pdf';     insert attach;     }     Please help..
82209
How can I render a VisualForce Page as PDF and have a button on the page that saves this PDF as an attachment to a record?  I want to have a button on my object detail page, 'Generate PDF' which will open a VisualForce Page for preview. On the Preview page I need a button to Save or Save and Email this PDF.  Edit - I use the professional edition + API enabled, so I cannot write a controller but maybe replace that with ajax toolkit?   Is that doable?
92236
I have an xml file which I would like to create a form/table around to add, edit and delete records using PHP.  Currently I use simpleXML to load the XML file, and display its content on various pages.  Is there any way I can create a table that shows all results, and allows me to either edit or delete that particular row of the table which represents a full record within the XML file.    When clicking edit I would like the details from the record to appear in a form which the user can change and then save out, updating the XML file and the corresponding web page.  I need this done in PHP, preferably using SimpleXML, though open to suggestions of other ways to do this with PHP.  Cheers
26203
I'm trying to direct a browser to a different page. If I wanted a GET request, I might say  document.location.href = 'http://example.com/q=a';   But the resource I'm trying to access won't respond properly unless I use a POST request. If this were not dynamically generated, I might use the HTML  &lt;form action="http://example.com/" method="POST"&gt;   &lt;input type="hidden" name="q" value="a"&gt; &lt;/form&gt;   Then I would just submit the form from the DOM.  But really I would like JavaScript code that allows me to say  post_to_url('http://example.com/', {'q':'a'});   What's the best cross browser implementation?  Edit   I'm sorry I was not clear. I need a solution that changes the location of the browser, just like submitting a form. If this is possible with , it is not obvious. And this should not be asynchronous, nor use XML, so Ajax is not the answer.
61666
In reading I am not sure if the issue below could have something to do with needing a custom wordpress ajax handler? All of these functions are inside my functions.php file. I have a couple of PHP functions that are supposed to pass information from one to another. The an AJAX call to the final function should produce the final result through that call. Its not happening. My count results in 0 and I am not understanding why. If I replace my query with a static array like [44,55,99,33] then it will pass the values ok. Likewise if I keep the query and simply replace the $id in the query and make it a static id such as '20' then it works. I would think that the id was the issue then and it wasnt pulling properly but it seems to work ok just not pass? function idx(){     global $wpdb, $id;       $getId = $_SERVER['REQUEST_URI'];     $ecp = explode('/', $getId);     if($ecp[3] != ''){         $id = $ecp[3];     }         return $id; } add_action( 'after_setup_theme', 'idx' );  =============================================== function Total_Result(){     global $wpdb;     $id = idx();        /*$resultx = [44,88,59,52];*/ ;      $resultx = $wpdb-&gt;get_results( $wpdb-&gt;prepare(&quot;SELECT * FROM {$wpdb-&gt;prefix}custom_form_submission_conversation as cc LEFT JOIN {$wpdb-&gt;prefix}custom_form_submission as cs on cc.fsid ='$id' WHERE fsid='$id'&quot; ));          $resultxs = array($resultx);          $total_result =  count($resultxs[0]);     echo  $total_result; }  when I var_dump $resultx I get: array(3) { [0]=&gt; object(stdClass)#1256 (36) { [“cid”]=&gt; string(3) “167” [“fsid”]=&gt; string(2) “20” [“specified_date”]=&gt; string(3) “yes” [“price_quote”]=&gt; string(4) “1140” [“posted_by”]=&gt; string(9) “dc_vendor” [“limit_count”]=&gt; string(1) “1” [“read_unread”]=&gt; string(1) “1” [“vendor_response”]=&gt; string(4) “zero” [“date_created”]=&gt; string(19) “2021-04-15 11:39:08” }   [1]=&gt; object(stdClass)#1257 (36) { [“cid”]=&gt; string(3) “186” [“fsid”]=&gt; string(2) “20” [“specified_date”]=&gt; string(3) “Yes” [“price_quote”]=&gt; string(3) “602” [“posted_by”]=&gt; string(8) “customer” [“limit_count”]=&gt; string(1) “1” [“read_unread”]=&gt; string(1) “1” [“vendor_response”]=&gt; string(4) “zero” [“date_created”]=&gt; string(19) “2021-04-15 11:39:08” }   [2]=&gt; object(stdClass)#1258 (36) { [“cid”]=&gt; string(3) “188” [“fsid”]=&gt; string(2) “20” [“specified_date”]=&gt; string(3) “yes” [“price_quote”]=&gt; string(4) “1017” [“posted_by”]=&gt; string(9) “dc_vendor” [“limit_count”]=&gt; string(1) “1” [“read_unread”]=&gt; string(1) “0” [“vendor_response”]=&gt; string(4) “zero” [“date_created”]=&gt; string(19) “2021-04-15 11:39:08” } }   so then I try and pass that data like so: function getvendorresponsestatus() {     global $wpdb; $id = idx();          $total_resultx = Total_Result($id);         die; }  Ive tried with and without the die();. The AJAX call is: setInterval(function(){     var ffiidd = jQuery('#ffiidd').val();     var ajaxurl = &quot;&lt;?php echo admin_url('admin-ajax.php'); ?&gt;&quot;;          jQuery.post(ajaxurl, {         action: &quot;vendorAjaxprog&quot;,         ffiidd: ffiidd     }, function(data) {         console.log(data);         jQuery.post(ajaxurl, {             action: &quot;getvendorresponsestatus&quot;, //&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; this is the action that calls the function             fsid : ffiidd         },         function(datas) {             console.log('+ datas);             jQuery('.cust_vendor_top').html(datas);         });         if(data == 0){}else{             jQuery('.ajaxreload').html(data);                                     }     });               }, 5000);/*==30 seconds==*/  So the question is why wont it pass along the query array information but it passes a basic array or it will pass if I change the id in the query to be static? I know the query is good because of when I var_dumped it, I have results before I get to the Total_Result() function.
87186
For the following pretty straightforward task: query a list of products from a DB and present it on a webpage, consider 2 setups:  Setup1: PHP script queries. All content is built on the server and the entire page is served back to the client.  Setup2: Static HTML "page skeleton" requesting content using AJAX. Received content is parsed on the client side using Javascript and rendered using innerHTML or similar.  Of course the second setup only makes sense when you have pages, categories and tags for the client user to choose from.  I need to compare these two, at least by means of:   time it will take content to be served user experience (setup1 is delivered as a whole, setup2 is delivered in "two parts") scalability - how do the setups compare when I have 100,000 queries daily   Any thoughts on the issue will be much appreciated.
88037
So i'm trying to submit a form using ajax, in my form i have the following:          $form['actions']['#type'] = 'actions';         $form['actions']['submit'] = array(         '#type' =&gt; 'submit',         '#value' =&gt; $this-&gt;t('OK'),         '#button_type' =&gt; 'primary',         '#prefix' =&gt; '&lt;div class="tc btn_pay relative"&gt;',         '#suffix' =&gt; '&lt;/div&gt;                         &lt;/div&gt;',         '#attributes' =&gt; array(             'class' =&gt; array('proximabold', 'tc', 'transition', 'no-underline', 'ph3', 'pv2', 'mb2', 'dib', 'white'),         ),         '#ajax' =&gt; [             'event' =&gt; 'click',             'callback' =&gt; '::updateTable',             'wrapper' =&gt; 'table-wrapper',             'progress' =&gt; [                 'type' =&gt; 'throbber',                 'message' =&gt; t('Verifying entry...'),             ],         ],     );   and a simple updateTable function:  public function updateTable(array $form, FormStateInterface $form_state) {     return "Hello World"; }   But when i click on submit i get the error: An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (2 MB) that this server supports.  I knew that the error is server side (Maybe i'm wrong), so i went to php.ini (i use PHP7) and update the following lines:  post_max_size = 6144M memory_limit = 6144M upload_max_filesize = 6144M max_file_uploads = 1000   but without luck, this configuration shouldn't be necessary as the request size is only 1.5KB
41163
I'm wondering what the preferred method is for dealing with AJAX calls. Should one use the same plugin php file to process the POST or a separate one? Which is cleaner or safer?
88861
I don't want to use jQuery, but I'd like to use Ajax to do file uploading. Is that possible?  If so, where can I find information/tutorial on it?
21618
I'm trying to add AJAX callback to form element that was previously rendered by AJAX but with no luck. Code below.   A bit of description. There are three main methods here:   buildForm - base form extraField - AJAX callback attached to ['month'] choosePerson - AJAX callback attached to: ['week_day']['hour']   In the buildForm method I create base form with AJAX callback on 'month' select element. In the AJAX callback you can find an extraField method. This method contains form element called 'hour' ($form['week_day']['hour']) and this element renders well. But this element also contains AJAX callback, which doesn't work, it does not generate 'person_container' element and the 'person' select.   Any idea how to ajaxify elements that previously were rendered by ajax?  class ReservationForm extends FormBase {    public function getFormId() {     return 'reservation_form';   }    public function buildForm(array $form, FormStateInterface $form_state) {      $form['month'] = array(       '#type' =&gt; 'select',       '#title' =&gt; $this-&gt;t('Select month'),       '#options' =&gt; array($this-&gt;t('January'), $this-&gt;t('February'), $this-&gt;t('March')),       '#ajax' =&gt; array(         'callback' =&gt; array($this, 'extraField'),         'event' =&gt; 'change',         'wrapper' =&gt; 'week-day',       ),     );      // Disable caching on this form.     $form_state-&gt;setCached(FALSE);      $form['week_day'] = [       '#type' =&gt; 'container',       '#attributes' =&gt; ['id' =&gt; 'week-day'],     ];   }    public function extraField(array &amp;$form, FormStateInterface $form_state) {     $month = $form_state-&gt;getValue('month');      $hour_options = array();      if ($month == '0') {       $hour_options[0] = $this-&gt;t('08:00');       $hour_options[1] = $this-&gt;t('09:00');       $hour_options[2] = $this-&gt;t('10:00');     }      if ($month == '1') {       $hour_options[0] = $this-&gt;t('12:00');       $hour_options[1] = $this-&gt;t('13:00');       $hour_options[2] = $this-&gt;t('14:00');     }      if ($month == '2') {       $hour_options[0] = $this-&gt;t('18:00');       $hour_options[1] = $this-&gt;t('19:00');       $hour_options[2] = $this-&gt;t('20:00');     }      $form['week_day']['hour'] = array(       '#type' =&gt; 'select',       '#title' =&gt; $this-&gt;t('Choose hours @month', array('@month' =&gt; $month)),       '#options' =&gt; $hour_options,       '#ajax' =&gt; array(         // tried with that callback too: [ $this, 'choosePerson']         'callback' =&gt; array($this, 'choosePerson'),         'event' =&gt; 'change',         'wrapper' =&gt; 'person',       ),     );      $form['week_day']['person_container'] = array(       '#type' =&gt; 'container',       '#attributes' =&gt; ['id' =&gt; 'person-container'],     );      $form['week_day']['person_container']['person'] = array(       '#type' =&gt; 'select',       '#title' =&gt; $this-&gt;t('Choose person'),       '#options' =&gt; ['John', 'Sarah', 'Peter'],     );      return $form['week_day'];   }    public function choosePerson(array &amp;$form, FormStateInterface $form_state) {     $form['week_day']['person_container']['person'] = array(       '#type' =&gt; 'select',       '#title' =&gt; $this-&gt;t('Choose person'),       '#options' =&gt; ['John', 'Sarah', 'Peter'],     );     return $form['week_day']['person_container'];   } }