New answers tagged

0

You might want to load all the items on the page at the same time, and use jQuery to display however many at a time. So for example: By default you could load (to the DOM) and hide all of them, then load 4 at a time using jQuery's slice Here's an example for my videos, however you could also hide the previous 4 videos before loading the next 4 to simulate ...


0

I looked into doing the same thing and in the end opted for a custom solution using thickbox as being less complex. Could be it's possible, but perhaps not worth the effort. The code is certainly not built for customisation as far as I could see. Open a thickbox modal with a search field Ajax search the post title with the user-entered search term Echo the ...


0

I've actually forgotten to create the function for uploading and attaching images. I've found the correct method into another question here Uploading Multiple Attachments From Front-End With A Description.


6

Problem "Serialization" is the act of turning a data-object into a string-representation. jQuery automatically serializes the data property before sending an AJAX request. The server then deserializes the GET querystring from the URL, and the request body for POST requests before populating PHP's request variables. Your code functioned as expected when ...


0

the problem is in the action parameter. In your javascript function please try: var newFormChange = jQuery("#term").val(); jQuery.ajax({ type: "POST", url: "/wp-admin/admin-ajax.php", data: { action: "my_test_action", newFormChange: newFormChange ...


3

Note that the action should be inside the data key. In your post request there is no key named as action therefore, the callback function is never being called. Consider this example:- jQuery.ajax({ type:"POST", url: "/wp-admin/admin-ajax.php", data: { action: "my_test_action", form_data : newFormChange }, success: ...


0

It seems there is a problem with at url: "/wp-admin/admin-ajax.php", instead try adding the full path: function addajaxurl() { wp_localize_script( 'frontend-ajax', 'frontendajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ))); } add_action( 'wp_enqueue_scripts', 'addajaxurl' ); and call the variable in your ajax function: ...


0

Found an answer by myself. Hope it will help others with the same issue. Basically, the search-everything plugin responds to an wp_ajax_{#action} type action. One 'problem' is that it only responds for logged-in users, so we must add a nopriv action to functions.php or the like: add_action('wp_ajax_nopriv_search_everything', 'search_everything_callback'); ...


2

From your site i can say that script is not being loaded because of wrong opening quote for script tag.Use " instead of ” So <script src=”http://lookbook.nu/widget/profile.js?id=2303472&width=standard&align=left&stats_fans=1&fanbox=yes&hash=14575a9cd02fd36d2758e5db3cb92b5a”></script> Should be this <script ...


1

Uncaught TypeError: Cannot read property 'ajax' of undefined @Sasa1234, it happen cause your jQuery is undefined. Please take a look @EAMann answer. So, your JS code should like this: function myajaxfunction() { if ( undefined !== window.jQuery ) { jQuery.ajax({ //ajax request url: ajaxurl, data: { ...


0

There can be many reasons for that. For the beginning I'd check if the session_start() returns true, and after that I'd make sure my ajax callback function is executed. Just put some die()s in your script.


0

It seems that I found a solution to this and it is pretty easy. So I'm gonna post all the code for future uses: single.php <?php get_header(); ?> <?php $post = get_post(); $post_cat = get_the_category($post); $data = collection_data_json($post_cat[0]->term_id, $post->ID); $data_details = collection_order_permalink($data); $author_id = ...


0

Here is a short plugin that adds the interim-login lightbox on every frontend page: <?php /* Plugin Name: Interim Login Everywhere Version: 1.0.1 Plugin URI: http://nowhere.com Description: Provide interim login screens on all pages. Author: S Valentine */ function ile_enqueue_scripts() { // we only care to add scripts and styles if the user is ...


2

I guess the issue with this line: $path = "wp-content/themes/creation/templates/inc/log.txt"; You need to use the full path, not a relative part, while using fopen() or file_exists(). Something like this should fix your issue: $path = get_template_directory() . "/templates/inc/log.txt"; get_template_directory() will return the absolute server path, ...


1

There is no action variable on the data you're passing to Ajax. This way WordPress is sending just a generic call to Ajax which always return 0. You must edit your data on your JS file to something like: data: { 'user_input': user_input_last, 'action': 'tags_autofill_function' },


0

I'm beginner in jQuery AJAX too, and I always tried with $.ajax, but I'm using just $.post to my requisitions now and they work well. The syntax is more simple and less risk to make a mistake. Obviously, if I'm wrong in this way, please someone alert me about it. In $.post() you need to put the url, the variable would get by POST as object and a handler ...


0

Maybe It's the Appropriate Answer for You! Accordingly to this question the more reasonable answer is to use wp_send_json() with (if only necessary) the wp_send_json_success() and wp_send_json_error() functions. They'll return an JSON Object back to the AJAX Request and it will automatically die() for you. It will look something like this: add_action( ...


1

I see two things. You're missing an action call - you need add_action( 'wp_ajax_render_admin_charts_page', 'render_admin_charts_page' ); add_action('wp_ajax_nopriv_render_admin_charts_page', 'render_admin_charts_page'); Plus, from looking at your render_admin_charts_page() you need to change your json dataType to html. Your charts function is outputting ...


0

I have figured out how to do this. It was somewhat close to what ankittiwaari suggested, but he didn't give a few key details. When you pass a variable under data in an ajax call, it automatically makes it a $_POST request assuming you are calling method: 'post' So I did what ankittiwaari said and created <input type="hidden" value="<?= ...



Top 50 recent answers are included