I'm making an web app that allow user to input form and generate word document. The form is relatively complex and I use a lot of jQuery and jQuery Mobile framework. I try to plugin the demo from opentbs ut it seems like it doesn't do anything when I have:
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
when I comment it out it looks fine.
Does any one has problem like that?
I also having problem to find the resources of how to modify the template within the docx.
I know here like variable that so I can modify it through php form but is there more detail documentation for it?
I found that there's nothing to do with opentbs it was jQuery that is assuming the post is ajax request therefore I cannot have file download (I am not sure if I am explaining it 100 percent correctly). However, I found the work around: put the script below right before jQuery Mobile script. It works for me.
<script>$(document).bind("mobileinit", function(){$.mobile.ajaxEnabled = false;});</scipet>
or this link in your htnl tag:
<a href="download.php?file=test.txt" rel="external">test.txt<a>
Related
Intro: I'm a newbie on both php and Javascript and have been trying to solve this issue for my site (another version of this issue here), but have had trouble putting into effect the answer by LocalPCguy.
(in short: the issue is that with infinite scroll activated, the social buttons work on the first posts that are loaded, but do not work for posts loaded subsequently).
I am working off of a WordPress them, and I've added my social buttons to an existing php file that generates most of the appearance of each post. I seem to be adding them to the right place because the buttons appear where I want them to on each post (only for the first ones on the page). Like the other two guys who posted about this problem, I am using digg digg as my social plugin.
Currently the code in the php file that generates the social buttons looks something like this:
<div class="sharing-button">
<?php dd_google1_generate('Compact (20px)') ?>
</div>
Like I said, this makes the button appear for the first posts that are loaded, but once the infinite scroll tries to load additional posts, the social button will not appear on those posts.
For now I have tried the following:
Add the code below just above or below (taken from the answer here), or inside my <div> containing the buttons in the php file.
if (typeof gapi !== "undefined") { gapi.plusone.go(); }
That didn't work I figured it was because a .php file would need some kind of signal to know that it needs to run a javascript operation. So I looked around and found a couple suggestions on how to do this, here and here. In neither case did I manage to get the buttons to appear appropriately. Below was what seemed like the least idiotic of those attempts:
<?php
echo '<script type="text/javascript">
if (typeof gapi !== "undefined") { gapi.plusone.go(); }';
echo '</script>';
?>
I also thought perhaps I needed to pass an argument into gapi.plusone.go(), and I tried passing my sharing-button <div> above, but that did not work either (php code inside a javascript script inside a php block... didn't have high hopes).
At this point I'm not sure what to do - I feel like the solution is probably quite simple but I'm completely stuck, having spent hours reading threads about javascript integration into php and the like.
Does anyone have an idea how I can go about applying that Javascript solution to my .php dependent Wordpress theme?
Many many thanks!
Short Answer: this is not possible.
Long Answer:
FIRST comes PHP, SECOND comes javascript.
The PHP "program" is run at the Server, which is you web provider's server. This server works out all the PHP stuff. After this one is finished, the files of the Website are sent to your computer. It contains, among other stuff, javascript.
And this javascript is only run on YOUR computer, the one you're looking at. Once your Browser loaded the page and starts running javscript, it's already too late to ask the Server for some more info.
There are techniques allowing for that (AJAX is the Keyword), but that's another question :-)
You need to initiate the javascript of the buttons for them to work since infinite scroll loads the next set of posts using ajax. One example I found but it only does it for facebook if the plugin uses FBML:
$(document).ajaxComplete(function(){
try{
FB.XFBML.parse();
}catch(ex){}
});
I'm using a custom implemented Like Box from facebook and infinite scroll and this works just fine.
I have been working on ajax for quite a while. I know about the hashtag and hashbang. Recently I have started using Code Igniter framework. Lets say I am in a page - http://domain.com/media, and there is a link called 'audio'.
When I click on this audio link, I send an ajax request, fetch the contents and display the content dynamically. But in such case the URL still remains the same (i.e.,) http://domain.com/media.
Now, is it possible to change the url to http://domain.com/media/audio when I click on the audio link and I still want to have the ajax functionality. I dont want to do it the usual way of the code-igniter (/controller/method).
Any help would be appreciated. Thanks in advance.
If it is not possible in Code Igniter, is it possible in any other framework?
You can use the pushState to achieve this.
Here's an example of my own site using it for browsing given images; no reloading occurs. I've also added support for each gallery image and it's loaded url, so that you can share the url with anyone without problems. The fallback is that if pushState is not supported, you will simply browse as you always do.
I know this has been asked by a few people but I haven't seen the answer. I have a php upload form for a file upload in a div tag. Is it possible to submit the form and upload the file without a page refresh? I haven't found the plugins to work because I want to submit the form with a title and other data attached as well. Any suggestions? I looked at using an iframe, but i'm not sure it will work in an upload.php wrapped in a div tag?
Here is the most simple solution you can use: Image upload without page refresh.
No obligation to use the javascript part, but it gives you the opportunity to show a notice that the transfer has been correctly done.
If you are open to jQuery and want a more open solution, I suggest you to take a look at the jQuery Form Plugin that can manage it all for you, with some extras that could be interesting.
My favourite tool for this is Uploadify. It includes real-time progress indicators, drag-and-drop, etc.
There are other, older solutions as well, including this one. That page has a simple demo that may provide a good example for how to do this on your own.
Honourable mention goes to Dave Walsh's facebook-lightbox, into which you might be able to put a file upload form. Worth a try if you like the look.
Try using something like AIM (http://www.webtoolkit.info/). And you should really get a little more experience on html, php and js.
I need to develop an embeddable widget which has to look something like this:
<div id="my_widget" data-api_key="xxx" data-shop_id="xxx"></div>
<script type="text/javascript" src="my_widget.js"></script>
The API Request must be in PHP implemented. I have to show the three more sold products for the shop by id data-shop_id.
I'm ok with the PHP coding, my problem is how to implement that my_widget.js and how to integrate it with a jQuery slider. And how do I use that data-api_key and data-shop_id labels in the PHP?
It would be OK to use <iframe> or is better pure JavaScript?
Sorry if it sounds a bit confuse, I'm still wondering how to do it. If you know some tutorial about how to implement a widget using PHP + JavaScript, I'd be pleased.
I think the easiest way would be to use an iframe.
Although you could use jQuery to post the data-shop_id and then receive the results as JSON and process them.
jQuery access data attribute - $(this).data("shop_id")
I'm currently using curl to login to a site and grab the html for one of the pages. My problem is that the page has some ajax links on it (click on the link results to html changes). How would I be able to make the clicks of the link and get the html of the final state using php? Seems like from researching this I need some sort of headless browser? Is there something like that in php I can use?
I'm not aware of any headless browsers that supports Javascript/AJAX that you can drive with PHP. If you want to drive a real browser with PHP, see http://seleniumhq.org/
Had this exact problem a few minutes ago. This works like a charm. Use .live() as the top answer here explains.
Reload javascript file after an AJAX request
Tested and works.