Title: jquery $.post
Last modified: August 21, 2016

---

# jquery $.post

 *  [cuk](https://wordpress.org/support/users/cuk/)
 * (@cuk)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/jquery-post/)
 * Hi!
 * I’m trying to post some data from the template php to another php which I added
   to wordpress files.
    This is a part of the code: `$.post('drugi.php', {name:tralala},
   function (data){...}` It seems it doesn’t send anything to drugi.php at all. 
   Is this first attribute wrong? Should i write the whole URL?
 * Please help.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 10 months ago](https://wordpress.org/support/topic/jquery-post/#post-3983878)
 * Are you receiving any JS errors?
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [12 years, 10 months ago](https://wordpress.org/support/topic/jquery-post/#post-3983884)
 * This should answer your question:
 * [http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers)
 *  Thread Starter [cuk](https://wordpress.org/support/users/cuk/)
 * (@cuk)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/jquery-post/#post-3983897)
 * [@andrew](https://wordpress.org/support/users/andrew/), nope. No errors. I fixed
   the URL problem, still it seems drugi.php doesn’t even get activated.
    [@samuel](https://wordpress.org/support/users/samuel/),
   wrappers didn’t solve the problem.
 * Sorry, now it does output some error, but the error’s about wpdb insert. I don’t
   know what made it change…
 *  Thread Starter [cuk](https://wordpress.org/support/users/cuk/)
 * (@cuk)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/jquery-post/#post-3983911)
 * I’m getting this:
 * Fatal error: Call to a member function insert() on a non-object in /home/a2865846/
   public_html/wp-content/themes/twentyeleven-dijete/trazilica_jedan.php on line
   4
 * This is the whole code from trazilica_jedan.php
 *     ```
       <?php
       if (isset($_POST['znamen'])){
         $lepo = $_POST['znamen'];
         $update = $wpdb->insert('users', array('user_id' => 12, 'uporabniki' => 'trajj'),array("%d", "%s"));
         echo "$update";
       }
       else {
         echo "napaka! :(";
       }
       ?>
       ```
   
 * It is activated from the template file trazilica_dva.php. This is the part:
 *     ```
       $.post('http://sklopnjak.uni.me/wp-content/themes/twentyeleven-dijete/trazilica_jedan.php', {znamen:znamen},function (data){
       			$('#save_status').text(data);
       			 });
       ```
   
 * Some ideas?
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [12 years, 10 months ago](https://wordpress.org/support/topic/jquery-post/#post-3984048)
 * You’re calling a PHP file in the theme directly and then attempting to use the
   $wpdb object, but because you called the file directly, WordPress isn’t loaded,
   and $wpdb is undefined.
 * You need to learn to use AJAX calls correctly in WordPress:
    [http://codex.wordpress.org/AJAX_in_Plugins](http://codex.wordpress.org/AJAX_in_Plugins)
 *  Thread Starter [cuk](https://wordpress.org/support/users/cuk/)
 * (@cuk)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/jquery-post/#post-3984101)
 * Hm, I read it and tried to alter the code, but it didn’t work…
    Any further help
   would be greatly appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘jquery $.post’ is closed to new replies.

## Tags

 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 6 replies
 * 3 participants
 * Last reply from: [cuk](https://wordpress.org/support/users/cuk/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/jquery-post/#post-3984101)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
