Results 1 to 5 of 5

Thread: Ajax value response, to run a certain function

  1. #1
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Ajax value response, to run a certain function

    I am very good at getting ajax to respond data from a php file and input that data into a certain div, but what im having problems with is coding an ajax response that will grab a value from a php file, then depending on that value ---- ajax will run a certain function i have specified.

    Something like this

    1) Ajax gets checkmsg.php?response=msgtrue
    2) Ajax reads the data(or output) from the php file (for example the response might be msgtrue)
    3) Ajax takes the value returned from php and runs some function
    4) that function runs and does what i specify it to do!

    Simply Put

    --- Ajax Request ----
    ---PHP data returned to ajax ---
    ---Ajax runs a function depending on php repsonse ---
    ---User sees the function ---

    i was trying to write a if statement in javascript, that states

    if (phpdata=msgtrue)
    {
    launch_some_function();
    }

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I think it should be this:
    Code:
    if (phpdata == msgtrue)
    {
    launch_some_function();
    }
    Jeremy | jfein.net

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Yep, shinkiwink was assigning a value, not comparing one.
    - Mike

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by mburt View Post
    Yep, shinkiwink was assigning a value, not comparing one.
    I know, thats why I corrected him.
    Jeremy | jfein.net

  5. #5
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks so much for the response i actually figured it out 15 minutes after i posted this. And that = sign i actually meant to put == in the first place. Guys thanks so much.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •