I have a question about the following. I want to automatically download a file which is not available through an URL, but through "javascript: postback()". It's about the following file: http://elia.be/repository/pages/877f075274f440d8a049107cfec0bddf.aspx and then the ".csv" button at the right hand side of the site (right side of 'Gegevens van de getoonde grafiek inladen'). How can I automatically download this data e.g. each hour and save the csv file on my computer?
It would be great if someone could help me. Thank you very much!!
You send a POST request to the following URL:
http://elia.be/repository/pages/877f075274f440d8a049107cfec0bddf.aspx
With the parameters outlined in the <form> element's children.
The magic parameter is ACTIONTARGET, and its value is DownloadCsv.GraphData.
Related
here's the situation:
I have a page generated from a custom post type in Wordpress.
This page has a custom metabox with a "thank you" message.
In this page there is a contact form generated with Contact Form 7.
What I would like to archive is that when someone submits the post, a ajax function replaces the form with the content in the metabox.
Now the content in the metabox has also some script (tracking codes) that I don't want to load before the the form is submitted.
Any suggestions?
Thanks in advance!
It is possible to do what you want but since you are using CF7 it requires quite a lot of customisation.
It would be way easier to achieve the desired result if you could hardcode the php form into the page.
Let me know if that's an option for you and maybe I can give you an hand.
I use CKE on my website. It is an full AJAX engine and all works fine with CKE, no problem with AJAX.
My little problem were when i want to work on links.
I edit an area, write a link like it :
<a href='#!idPage' title='Name of page' >Name of page</a>
No problem to record it and use it.
But when i come back to edit it, CKE don't recognize it !
And all the input are empty, no name, no link, ... i must write them again :(
For CKE it is not an HTTP link and not an ANCHOR too.
It not start with http or # but #! like GOOGLE advice to use.
How can we fix that ?
Thanks
Today i try to make some modif in CKE link.js
edit line 80 : urlRegex = /^((?:(?:http|https|ftp|news):\/\/)|(?:#!))?(.*)$/,
add line 375 [ '#!\u200E', '#!' ],
edit line 401 : urlOnChangeProtocol = /^(?:(?:http|https|ftp|news):\/\/)|(?:#!)(?=.)/i,
It is better, but always not edit my link :(
I put a Ajax link using the following code:
echo chtml::ajaxLink('GO', 'http://localhost/index.php?r=user/delete', array('method'=>'POST'));
But, regardless of giving the second parameter as URL i,e 'http://localhost/index.php?r=user/delete'. It generates link with the current URL in the browser not the URL I just specified.
What is the issue? How could I create AJAX link? Google several hours but can't solve the issue.
Any kind of help is highly appreciated.
First of all, you should always try and create normalized urls.
But i think your doubt lies in the # that is generated/appended. If you go and check the source of yii ajaxLink you'll see this:
public static function ajaxLink($text,$url,$ajaxOptions=array(),$htmlOptions=array())
{
if(!isset($htmlOptions['href']))
$htmlOptions['href']='#';
$ajaxOptions['url']=$url;
$htmlOptions['ajax']=$ajaxOptions;
self::clientChange('click',$htmlOptions);
return self::tag('a',$htmlOptions,$text);
}
so if you don't set the href property of the a tag in the htmloptions array, the # will be appended.
You should also understand that yii uses jquery, so if you check out the source of the page, you'll see at the bottom, how jquery is used to carry out an ajax request, your actual url that is called will also be seen in that script. So the third option/parameter in ajaxLink is for options for jquery's ajax function. You can create better ajax links using this option.
Regardless of where(which controller) your url points to in your project, the action associated with that url will be called.
So anyway, you can modify your code like this if you want the url to be shown and not a # :
echo CHtml::ajaxLink('GO', 'http://localhost/index.php?r=user/delete',
array('type'=>POST), //there are various other options for jquery ajax
array('href'=>'http://localhost/index.php?r=user/delete'));
To make better ajax links i would suggest going through jquery's ajax documentation. There is an option for a success function, that you can use to let the user know that the operation was completed.
Hope this helps, don't hesitate to leave comments if i haven't answered your question completely.
Have you tried:
echo CHtml::ajaxLink('GO', array('/user/delete'), array('method'=>'POST'));
as the ajaxLink documentation suggests...? Look also at the normalizeUrl method.
Using these methods, which in turn are using createUrl, is usually better since it will take care to create a valid url for your site.
I had the same issue(or maybe similar).
I've used renderPartial to load view and later in that view i was using ajaxLink and it was not working.
What i have found, that when using renderPartial, there was no jquery script for ajax action.
What you have to do is to add 4th argument(true) in renderPartial function to generate jquery script.
See the documentation: http://www.yiiframework.com/doc/api/1.1/CController/#renderPartial-detail
Hope it helps and saves time to figure it out.
I want to paste some text to a pastebin site through the site's API.
As I have figured out (I have limited knowledge of programming) I need two things: First to process the selected text and then to post it via HTTP POST to the pastebin site.
I tried to do this...
javascript:'<body%20onload="document.forms[0].submit()"><form%20method="post"%20action="http://sprunge.us"><input%20type="hidden"%20name="sprunge"%20value="+ document.getSelection() +"></form>'
....which (you guessed it!) returns to me EVERY TIME a page in which the selected text being "+ document.getSelection() +".
Any help?
You have to make a form programmatically, add the fields required and then post -- all in JavaScript.
Here is an example -- you will at least have to change the URL and the fieldname:
<a href="
javascript:(function(){
var myform = document.createElement('form');
myform.method='post';
/* change this URL: */
myform.action='http://my-example-pastebin.com/submit.php';
/* The goodies go here: */
var myin=document.createElement('input');
/* Change the fieldname here: */
myin.setAttribute('name','fieldname_for_pasted_text');
myin.setAttribute('value',document.getSelection());
myform.appendChild(myin);
/* If you need another field for username etc: */
myin=document.createElement('input');
myin.setAttribute('name','some_field_1');
myin.setAttribute('value','some_field_value_1');
myform.appendChild(myin);
myform.submit();
})()
">Bookmarklet for posting selected text to an online pastebin</a>
The above compacted without comments and linebreaks:
Bookmarklet for posting selected text to an online pastebin
I'm not familiar with sprunge.us, but if you've got the URL and fieldname right in your example, you could get this to work by search-replace:
http://my-example-pastebin.com/submit.php → http://sprunge.us/
fieldname_for_pasted_text → sprunge
You should also remove the second field (some_field_1, somefield_value_1) included in my example.
I am trying to use CodeIgniter and jQuery-ui dialog to create a modal window with form to update user information.
The process should be like:
1. Press a button on a view page.
2. A modal window pops up.
3. Inside the window is a form that a user can fill.
4. If the user filled something before, the information should be shown in corresponding field
5. Click the update button on the modal window to save the changes to database.
Can anyone provide a good sample of this process?
I used ajax to pass the data but it didn't work when I was trying to update the data to the database. It would be nice if an example of how to pass data from ajax to php and how php handle that.
Thanks,
Milo
well the jquery bit for post(), get(), ajax() works the same in any measure you would normally use it.. key difference here is with CI you can't post directly to a file-name file-location due to how it handles the URI requests. That said your post URL would be the similar to how you would access a view file normally otherwise
ie: /viewName/functionName (how you've done it with controllers to view all along. post, get, ajax doesnt have to end in a extension. I wish I had a better example then this but I can't seem to find one at the moment..
url = '/home/specialFunction';
jQuery.get(url, function(data) {
jQuery("#div2display").html(data);
});
in the case of the above you notice despite it not being a great example that. you have the url with 2 parameters home and specialFunction
home in this case is the controller file for home in the control folder for the home file in views the specialFunction is a "public function" within the class that makes the home controller file. similar to that of index() but a separate function all together. Best way I have found to handle it is through .post() and a callback output expected in JSON cause you can form an array of data on the php side json_encode it and echo out that json_encode and then work with that like you would any JSON output. or if your just expecting a sinlge output and not multiples echoing it out is fine but enough of the end run output thats for you to decide with what your comfortable doing currently. Hopefully all around though this gives you some clairity and hopefully it works out for you.