How to implement a plugin featuring foursquare like check-in
I would use an AJAX call + modal dialog. And for the API, just create a plugin, and follow the steps on this page to create your own custom ajax action.
I would use an AJAX call + modal dialog. And for the API, just create a plugin, and follow the steps on this page to create your own custom ajax action.
hmmm…. I don’t see a problem with your code. When I run into 500, it’s usually due to permissions or htaccess mis-routing the request. That said, some things to try: 1) in wp-config.php, set debug WP_DEBUG to true. This may offer a more descriptive error message. 2) WordPress has good integration for AJAX. You can … Read more
You’ll need to hook into the “onchange” event of javascript. When using jquery, it’s as simple as $(‘<the selector string>’).change(function(){}); When ever the values are changed, you’ll do an AJAX request to the server with the new parameters & populate the output screen with the new result. For the server-side, you’ll check the parameters, do … Read more
You have an error on this line: var appendHTML = ‘<div class=”ajax-loading-screen appended”> Be careful with multi-line string in Javascript. It doesn’t work the way it does in PHP. https://stackoverflow.com/questions/805107/how-to-create-multiline-strings
Based on your comments above, you are just passing a wrong id or you need to modify delete_pdf_and_metadata function. intval(‘aps_pdf1’) is 0, and that’s why your response is 0!
In short: do not use a single.php. If you only have a index.php, than all posts are displayed with this template because WP can not find any other template to display the content. Your problem in a human language: If the url is www.youpiemonday.com, load the frontpage (index.php, home.php or what else) If the url … Read more
add_action and add_filter always return true. And yes, in PHP, any string that is not empty or “0” is loosely equal to the boolean true. And I see nothing wrong with your die code. It’s hooked to wp_ajax_my_action, so you need to make a call to the admin-ajax.php as an authenticated user, with the my_action … Read more
Simply add a Success callback to your Ajax function: $(‘#sendEmail’).click(function(){ $.ajax({ type: ‘POST’, url: ‘www.example.com/email.php’, data: { content: $(‘#email-data’).html()}, success: function(data) { //data variable can be used if your ajax call returns something do_stuff_here(); } }); }); In your case, you could do something like success: function() { $(‘body’).append(‘<div class=”success”>Success!</div>’); } However, is there a … Read more
Yes, if you need to run WordPress/PHP functions from a button click (Javascript), you need Ajax. In the following example, a shortcode will render a button (id=”newquote”) that calls an Ajax action hook (get_random_cpt). A query is done and replaces one div from that shortcode (id=”randomquotes”) with the results. How to Use Ajax in a … Read more
You should use the WP AJAX APIs rather than reinventing them in your home template, e.g.: functions.php : // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php) wp_localize_script( ‘my-ajax-request’, ‘MyAjax’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ) ) ); add_action(‘wp_ajax_my_action’, ‘my_action_callback’); add_action(‘wp_ajax_nopriv_my_action’, ‘my_action_callback’); function my_action_callback() { $content=”something to send back to the … Read more