New answers tagged

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.


5

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 ...


2

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: ...


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

Just a little test here. I peeked into jquery-migrate.js and noticed this part: // Set to true to prevent console output; migrateWarnings still maintained // jQuery.migrateMute = false; so I tested the following with the newly wp_add_inline_script(), introduced in version 4.5: add_action( 'wp_enqueue_scripts', function() { wp_add_inline_script( ...


3

You could change the log message text to blank in jquery-migrate.min.js but this will not be preserved on core update. The alternative is to add passthrough/filter function copy of console.log to just before the migrate script is loaded, and tell it to ignore logging messages that contain 'Migrate is installed'. Doing it this way will preserve other Migrate ...


8

WordPress uses the jQuery migrate script to ensure backwards compatibility for any plugins or themes you might be using which use functionality removed from newer versions of jQuery. With the release of WordPress 4.5, it appears they have upgraded the version of jQuery migrate from v1.2.1 to v1.4.0 - Having a quick scan through the code reveals that v1.4.0 ...


2

WP loads jQuery in no conflict mode so shortcut $ is not available for jQuery to use .You should not use the $ variable for jQuery within WordPress. jQuery(function ($) { //code here }) or (function($){ //code here })(jQuery); There are so many Q&A which refers to the same conflict issue.Check this and this.


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.


1

Not allow. Your user is not a software developer, pretending that he is can only end bad. This is even before speaking about security etc. If you think that there are callbacks that make sense, just provide them yourself.


1

Never let anyone add any jQuery scripts via any text editor. How are you going to know if the script is malicious or not, how are you going to handle jQuery errors, how are you going to know if the jQuery is even proper and allowed jQuery. eval() brings an added extra security risk and should be avoided where user submitted strings are to be evaluated. ...


0

Add the menu_class argument with value of cd-accordion-menu to your code, so that it looks like this: <div class="menu-container"> <nav id="site-navigation" class="main-navigation" role="navigation"> <?php wp_nav_menu(array( 'theme_location' => 'primary', 'sort_column' => 'menu_order', 'menu' => ...


0

So I finally found the solution to the problem. It was in the validate.js function. I corrected the error by calling the outside functions of validate.js and jquerry: script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.min.js" script type="text/javascript" ...


0

Provided you've confirmed that WP's native 'suggest' script is actually being rendered on the page properly (ie. you're using the correct template for home vs front-page), sometimes to avoid script conflicts on the page, you need to wrap your script in an anonymous function. So something like: <script> (function($) { ...


0

To achieve this, it was simply a matter of overwriting the plugin's jQuery functions in a custom .js file, and enqueueing it in my theme in the footer, ensuring it was placed after the Contact Form 7 javascript include. I created a wpcf7-override.js file. I'm using Gulp to concat my custom js into a single js file; I'm using FoundationPress so it all gets ...


0

Ok, the code is fine, the problem is that the target button[data-id="select-especialidad"] is being used by bootstrap-select and even if the script load before my code, it takes a few seconds or less to process the information. So the code should be wrapped after a function that checks that the event has been loaded. This is the final code: ...


1

Found a solution. Turns out the activate, deactivate functions are not persistent, meaning the controls' state are reset if the page is refreshed! Therefore I used 'active_callback' => 'fname' in my customizer.php in order to make changes persistent where fname is the function name as seen below. function fname() { if ( !strcmp ( ...


2

You forgot to set dependencies at third parameter put it with array() or array('jquery') if you want to depend on jQuery wp_register_script( 'navbar-scroll', 'http://www.classyclutter.net/wp-content/themes/foodiepro/assets/js/scrolling-navbar.js', array(), '1.0.0', true);


1

Seems like you'd be better off saving your script in a .js file and then enqueuing your script using wp_enqueue_script() instead of wp_footer. That way you can designate jquery as a dependency for your script. wp_enqueue_script( 'myscript', 'path/to/myscript.js', array( 'jquery' ), false, true ); This also separates your js out of your php into a proper ...


1

You are trying to load your inline js script after jQuery just by calling add_action( 'wp_footer', 'myscript' ); after wp_enqueue_script( 'jquery' ); But this will not load your myscript after jQuery. It is not how wp_footer and wp_enqueue_script works. wp_footer has a third argument named "priority". add_action( 'wp_footer', 'your_function', 100 ); ...


0

I have solved my problem using below code.So may be helpful for someone.I have tried by reference style for autocomplete <script> var locations = '<?php echo $json;?>'; var locations_array = JSON.parse(locations); locations_array.sort(); function monkeyPatchAutocomplete2() { jQuery("#result").remove(); // Don't ...


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

You need to add your script though: Using wp_enqueue_script() in themes function.php or Use wp_footer action to add your jQuery script. If your html in a shortcode then register your script using wp_register_script('YOUR_HANDLE_NAME) and use wp_enqueue_script('YOUR_HANDLE_NAME) Hope It helps...


0

First thing you do about this issue is try to check if the button calls the jquery function. for example: $(#submit-button).click(function(){ alert('button was clicked!'); // to display an alert }); or using the console $(#submit-button).click(function(){ console.log('button was clicked!'); // check using web browser console }); If one ...



Top 50 recent answers are included