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

  • Home
  • SEARCH
  • 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 6139133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:57:06+00:00 2026-05-23T17:57:06+00:00

I have an ajax function and while caling that function the php code will

  • 0

I have an ajax function and while caling that function the php code will execute and check if any rows with the given data is present in the table. If there is no data I would like to display an alert. right now I can display a div with the error message but I could not get the out put such as

echo "<script> alert('error'); </script>";
  • 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-23T17:57:07+00:00Added an answer on May 23, 2026 at 5:57 pm

    You can not stick JavaScript on the page using innerHTML since it will not be evaluated. What you would need to do is parse out the JavaScript code and shove it into eval(). OR use a framework that does it for you like jQuery.

    It is better to develop a framework on the client that does not rely on this eval. A better messaging system would work.

    { "alert" : "Your alert message", "html" : " the mark up " }
    

    Basic JavaScript idea:

    //get the responseText
    var result = xhr.responseText;
    var json = JSON.parse(result); //This line is not cross browser for older browsers
    if(json.alert){
      alert(json.alert);
    }
    if(json.html){
      document.getElementById("out").innerHTML = html;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery-ajax function that sends data to a php script and the
I have some jQuery code. I have called an Ajax function file, file.php, that
Hey guys I have an ajax jquery function that receives data from a php
I have the following code that works on Firefox and Chrome $("#adicionarItem").click(function(){ $.ajax({ type:
I have a pretty simple AJAX and PHP code. While calling the PHP through
I have a basic ajax application, which will not work, instead the php code
I have the following code: public function ajax() { // Contains results $data =
I have $.ajax({ url: identity, success: function(data) { ProcessIdentityServer(data) } }); When 'data' is
I have this code $(.insert).click(function(){ $(.insert).ajaxStop(function(){ $(.load).hide(); }); $(.insert).ajaxStart(function(){ $(.load).show(); }); $.ajax({ type: GET,
I have an Ajax call that currently needs to be synchronous. However, while this

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.