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 8434229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:36:00+00:00 2026-06-10T06:36:00+00:00

I am submitting a simple form via Ajax POST and getting back a JSON

  • 0

I am submitting a simple form via Ajax POST and getting back a JSON response, and using that response to populate the data into a custom-built audio player with a slider.

The audio player slider functions work before the Ajax POST. However, after I submit my form, it appears that jQuery Mobile is refreshing the page, and after that refresh, the slider is broken.

The error message I get is: “Error: cannot call methods on slider prior to initialization; attempted to call method ‘refresh'”

My form code looks like:

<form name="test" method="post">
    <input type="hidden" name="action" value="test.php">
    <input type="number" name="id" />
    <button data-icon="star" onclick="onFormSumbit();">Submit</button>
</form>

And my submit function looks like:

function onFormSumbit() {
    $.ajax({
        type: $('form').attr('method'),
        url: $('form input[name=action]').attr('value'),
        data: $('form').serialize(),
        dataType: 'json',
        success: function(response, textStatus, XMLHttpRequest) {
            if (response.error) {
                console.log('ERROR: ' + response.error);                
            } else {
                mediaSource = response.url;                 
                console.log('URL: ' + response.url);
                console.log('ARTIST: ' + response.artist);
                console.log('TITLE: ' + response.title);
            }
        }
    });
}

My slider coded looks like:

<input type="range" id="slider" value="0" min="0" max="100" step="0.01" data-highlight="true" />

And my slider function looks like:

playSlider.on('slidestop', function(event,ui) {
    mediaObject.seekTo((playSlider.val() / 100) * mediaDuration * 1000);
    console.log(playSlider.val());
});
  • 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-06-10T06:36:01+00:00Added an answer on June 10, 2026 at 6:36 am

    I modified your code as following and the page is not refreshing:

    $(document).on('submit', '#myForm', function(e) {
        e.preventDefault();
        postForm();
    });
    
    function postForm()
    {
        $.ajax({
            type: $('form').attr('method'),
            url: $('form input[name=action]').attr('value'),
            data: $('form').serialize(),
            dataType: 'json',
            async: true,
            success: function(data) {
                mediaSource = response.url;                
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert("Error: " + xhr.status + "\n" +
                       "Message: " + xhr.statusText + "\n" +
                       "Response: " + xhr.responseText + "\n" + thrownError);
            }
        });
    }
    
    <form name="test" id="myForm" method="post">
       <input type="hidden" name="action" value="test.php">
       <input type="number" name="id"/>
       <input type="submit" data-icon="star" value="Submit">
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im submitting Data to a php file via AJAX using POST. It worked fine
I'm having trouble submitting some hidden form data via post from the following function:
I am currently submitting a simple PHP form via JavaScript using document.add_driver.submit(); This method
I'm submitting a form via ajax and trying to update a simple progress bar
I've created a simple upload-form and got a little problem when submitting the data.
I have a simple web form that feeds into Infusionsoft. Not my call. I
This is a simple form for submitting a listing into a database of real
I am submitting a form in spring g MVC using ajax. The form is
simple normal form that's submitting an action. <form id=myAppSearchForm method=get action=<%= search_path %>> <fieldset>
I am using a simple form and submitting my textbox values to database, <body>

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.