Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7191025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:38:29+00:00 2026-05-28T19:38:29+00:00

Real deal problem for me, because I have no clue to resolve it. jQuery

  • 0

Real deal problem for me, because I have no clue to resolve it.

jQuery script I wrote should grab the input value on “paste” action and pass it by ajax to codeigniter controller.

It actually works fine, but only if I paste the value for the second (and further) time. It works fine too when I change on(“paste”) to on(“click”) for some div or other DOM element.

Script:

<script type="text/javascript">
$("#link").on("paste", function(){
$("#thumbs").empty().html("<p>loading</p>");
var postData = {
  'url' : $("#link").val()
 }; 

 $.ajax({
     type: "POST",
     url: "/thumb/ajax/",
     data: postData , //assign the var here 
     success: function(msg){
    $("#thumbs").html( "Data Saved: " + msg );
     }

});

});

Any help would be appreciated

EDIT: one more hint.

val() in this particular script actually takes value before the paste action.
If i write something to this input, then remove it and paste something else it would actually pass to the controller the value i wrote, not the one I pasted.

EDIT2:
OK, I’m pretty sure that’s jQuery problem with paste.

<script type="text/javascript">

    $("#link").on("paste", function(){
        $("#thumbs").empty().html("<p>loading</p>");
        var postData = {'url' : $("#link").val() }; 
        $("#thumbs").html($("#link").val());
    });


</script>

This script should add value from input to div#thumbs. It doesn’t for the first paste action. On second it’s actually works.

EDIT3: My friend gave me a hint. on(“paste”) works right on “paste” action and before the paste is actually done. If anyone give me a hint how to make a timeout to grab the value after the paste I can move on.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:38:31+00:00Added an answer on May 28, 2026 at 7:38 pm

    Problem solved.

    Like I said before, “on(“paste”)” action is being done right on the actual paste. So function is being done before the value is pasted to the input. That’s because first time paste grabs and pass the default value of the input (null for my example).

    Solution is to set the timeout. Right code looks like that and works just fine.

    $("#link").on("paste", function(){
    
    setTimeout(function() {
        $("#thumbs").html("<p>loading</p>");
        var postData = {
          'url' : $("#link").val()
          };
        $.ajax({
             type: "POST",
             url: "/thumb/ajax/",
             data: postData , //assign the var here 
             success: function(msg){
            $("#thumbs").html( "Data Saved: " + msg );
                $(".thumb").click(function(){
                (this).attr('id');
    
    
            });
    
             }
    
        });
    }, 500);
    

    });

    Problem solved, thanks @3nigma for support.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Real UID, effective UID, and some systems even have a saved UID. What's the
REAL newbie here to Objective C and Cocoa. I have this 'if statement' if
Real problem with an existing webapp which has been working for the last couple
I'm having a real problem tracking down why i'm getting the error $(#checkIn).datepicker is
I have an R script that is shared with several users on different computers.
I have the following problem. My application has a tab bar at the bottom
I want to store real value in SQlite. but when i insert the value
I have a problem where, due to previous people's poor design decisions, I'm forced
What real-world projects would you suggest looking through the sources? As I'm learning Java
What real (i.e. practical) difference exists between a static class and a singleton pattern?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.