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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:20:24+00:00 2026-06-01T03:20:24+00:00

The title may sound confusing but it actually isn’t, I just didn’t know how

  • 0

The title may sound confusing but it actually isn’t, I just didn’t know how to explain it. So my home page has a script which loads an external php file for a section of my website. Inside that php file, I need to call a function, with parameters, inside the main javascript file(the file that loaded it). I have tried .bind("click", parameter1, paramter2, loadFunction);, the expanded version of that and .click({...}) but I can’t get it to work. How would I go about doing this? I don’t want to put the code that I need to call inside the php file because it is calling another ajax request(yes my site is ajax heavy) and don’t want people to find it that easy, I would rather it be buried in my javascript file. Thanks for any help! If you need any more info, let me know.

  • 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-01T03:20:25+00:00Added an answer on June 1, 2026 at 3:20 am

    You may say it isn’t confusing, but it is, a little. 😉 My answer is based on the following flow of events:

    1. An Ajax call is made from a function defined in your main JS.
    2. The PHP acts on given parameters, does “something”, and returns a result
    3. The returned result may NOT contain more script to execute, however, more script DOES execute depending on the contents of the returned result.

    This statement: “I would rather it be buried in my javascript file” sends up a red flag for me. If anyone cares to know what your site is doing, they’ll figure it out whether the script is in a minified JS file or not. I would argue that returning a script is actually going to be more secure because the scope will be limited.

    That said, I wouldn’t return a script anyhow. The very premise of the problem is its own answer.

    1. Make your Ajax call, passing parameters to PHP in a query string or in POST data.
    2. Your PHP processes the parameters and returns a response.
    3. The success function of the Ajax call grabs the response, perhaps encoded in JSON for nice and easy processing, and then fires up a function call scoped in the main application.

    I honestly can’t tell where the bind and click failures even factor into the equation. Are you not able to bind click for the first Ajax call in the first place? I imagine if your site is Ajax-heavy you already know how to do this, no?

    [response to comment]

    If your PHP generates and returns JSON, you can do whatever you want with it:

    {
        "content": "<div>Some HTML</div>",
        "action": "append_and_refresh",
        "recordsDeleted": 5
    }
    

    In the success function all you have to do is process it however you want:

    success: function(data) {
      $('#someDiv').html(data.content);
      if(data.action == "append_and_refresh") {
        doAppend();
        doRefresh();
      }
      recordsDeleted += data.recordsDeleted
    }
    

    An intentionally simplified example, but hopefully you get the picture!

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

Sidebar

Related Questions

I understand the title may sound confusing, but the goal is very clear: I
The title may be a little confusing, but I don't know how else to
The title may have been confusing, but please let me explain: Currently when I
The title may sound confusing. But here's my issue. I want to show something
I know that the title may be confusing (or even misleading), but I'm planning
The title may sound simple and dumb, but allow me to explain. I am
I know the title may be funny for you but I am actually facing
I know that the title may sound absurd, but I don't know ho to
Title may be confusing, but here's explanation with code. Based on some conditions, I
Hey all, title may be abit misleading but i didnt know the correct way

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.