Problem using StartCoroutine and IEnumerator

This is my code

public void funtion(){ JsonFx.Json.JsonWriter writer =new JsonFx.Json.JsonWriter(); string jsondata2=writer.Write(fps); print ("sSSSSSSSSSSSSSSSSss"+jsondata2); WWWForm form = new WWWForm(); form.AddField("facprodstrans", jsondata2); string url="127.0.0.1/few/get_trans.php"; www = new WWW(url,form); StartCoroutine(WaitForRequest(www)); print ("<<<<<<<<<<<<<"+fpts.time_remaining); } IEnumerator WaitForRequest(WWW www){ yield return www; string facpdata = www.text; print ("facSendJson&&&&&&&" + facpdata); JsonFx.Json.JsonReader reader = new JsonFx.Json.JsonReader (); fpts = reader.Read<FactoryProdTransS> (facpdata); print(">>>>>>>>>>>>>"+fpts.time_remaining); }
The print statement in my function executes before the print statement in my IEnumerator, due to which it prints the old value first and the updated value afterwards, can not figure out why.

The print statement executes before since www is not loaded yet and coroutine schedules another update with “yield return www”. Then execution continues and prints the old “fpts.time_remaining” value. After that when www is ready and “yield return www” line can not schedule another update, new “fpts.time_remaining” value is printed.

public void funtion()
    {
     JsonFx.Json.JsonWriter writer =new JsonFx.Json.JsonWriter();
     string jsondata2=writer.Write(fps);
     print ("sSSSSSSSSSSSSSSSSss"+jsondata2);
     WWWForm form = new WWWForm();
     form.AddField("facprodstrans", jsondata2); 
    string url="127.0.0.1/few/get_trans.php";
     www = new WWW(url,form); 
    StartCoroutine(WaitForRequest(www));
     print ("<<<<<<<<<<<<<"+fpts.time_remaining); 
    } 
    
    IEnumerator WaitForRequest(WWW www)
    {
     yield return www; 
    string facpdata = www.text;
     print ("facSendJson&&&&&&&" + facpdata);
     JsonFx.Json.JsonReader reader = new JsonFx.Json.JsonReader (); 
    fpts = reader.Read<FactoryProdTransS> (facpdata);
     print(">>>>>>>>>>>>>"+fpts.time_remaining); 
    }